種類
- インスタンスメソッド (27)
- 特異メソッド (22)
- クラス (18)
- モジュール関数 (11)
- 定数 (11)
クラス
-
Thread
:: ConditionVariable (36) - Time (13)
モジュール
- Process (22)
キーワード
-
CLOCK
_ SECOND (11) - ConditionVariable (18)
- at (13)
- broadcast (9)
-
clock
_ gettime (11) - new (9)
- signal (9)
- wait (9)
検索結果
先頭5件
-
ConditionVariable (18002.0)
-
Alias of Thread::ConditionVariable
...Alias of Thread::ConditionVariable... -
Thread
:: ConditionVariable (18002.0) -
スレッドの同期機構の一つである状態変数を実現するクラスです。
...一つである状態変数を実現するクラスです。
以下も ConditionVariable を理解するのに参考になります。
https://ruby-doc.com/docs/ProgrammingRuby/html/tut_threads.html#UF
=== Condition Variable とは
あるスレッド A が排他領域で動いていたとしま......な状況を解決するのが Condition Variable です。
スレッド a で条件(リソースが空いているかなど)が満たされるまで wait メソッドで
スレッドを止めます。他のスレッド b において条件が満たされたなら signal
メソッドでスレッド......mutex = Mutex.new
cv = ConditionVariable.new
a = Thread.start {
mutex.synchronize {
...
while (条件が満たされない)
cv.wait(mutex)
end
...
}
}
b = Thread.start {
mutex.synchronize {... -
Thread
:: ConditionVariable # wait(mutex , timeout = nil) -> self (15202.0) -
mutex のロックを解放し、カレントスレッドを停止します。 Thread::ConditionVariable#signalまたは、 Thread::ConditionVariable#broadcastで送られたシグナルを 受け取ると、mutexのロックを取得し、実行状態となります。
...mutex のロックを解放し、カレントスレッドを停止します。
Thread::ConditionVariable#signalまたは、
Thread::ConditionVariable#broadcastで送られたシグナルを
受け取ると、mutexのロックを取得し、実行状態となります。
@param mutex Mutex オブ......timeout スリープする秒数を指定します。この場合はシグナルを受け取
らなかった場合でも指定した秒数が経過するとスリープを終了
します。省略するとスリープし続けます。
@see Thread::ConditionVariable#si......gnal, Thread::ConditionVariable#broadcast... -
Process
. # clock _ gettime(clock _ id , unit=:float _ second) -> Float | Integer (12302.0) -
POSIX の clock_gettime() 関数の時間を返します。
...POSIX の clock_gettime() 関数の時間を返します。
例:
p Process.clock_gettime(Process::CLOCK_MONOTONIC) #=> 896053.968060096
@param clock_id クロックの種類を以下の定数のいずれかで指定します。
サポートされている定数は OS やバー......ocess::CLOCK_REALTIME
SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12
: Process::CLOCK_MONOTONIC
SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12
: Process::CLOCK_PROCESS_CPUTIME_ID
SUSv3 to 4, Linux 2.5.63, OpenBSD 5.4, macOS 10.12
: Process......THREAD_CPUTIME_ID
SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12
: Process::CLOCK_VIRTUAL
FreeBSD 3.0, OpenBSD 2.1
: Process::CLOCK_PROF
FreeBSD 3.0, OpenBSD 2.1
: Process::CLOCK_REALTIME_FAST
FreeBSD 8.1
: Process::CLOCK_REALTIME_PRECISE
FreeBSD 8.1
: Process::CLOCK_REALTIME_C... -
Process
:: CLOCK _ SECOND -> Integer (12302.0) -
Process.#clock_gettime で使われます。
...Process.#clock_gettime で使われます。
システムによっては定義されていません。... -
Thread
:: ConditionVariable . new -> Thread :: ConditionVariable (12302.0) -
状態変数を生成して返します。
状態変数を生成して返します。 -
Thread
:: ConditionVariable # signal -> self (12202.0) -
状態変数を待っているスレッドを1つ再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。
...read::ConditionVariable#wait
で指定した mutex のロックを試みます。
@return 常に self を返します。
//emlist[例][ruby]{
mutex = Mutex.new
cv = ConditionVariable.new
flg = true
3.times {
Thread.start {
mutex.synchronize {
puts "a1"
while (flg)
cv.wai......t(mutex)
end
puts "a2"
}
}
}
Thread.start {
mutex.synchronize {
flg = false
cv.signal
}
}
sleep 1
# => a1
# => a1
# => a1
# => a2
//}... -
Thread
:: ConditionVariable # broadcast -> self (9102.0) -
状態変数を待っているスレッドをすべて再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。
...read::ConditionVariable#wait
で指定した mutex のロックを試みます。
@return 常に self を返します。
//emlist[例][ruby]{
mutex = Mutex.new
cv = ConditionVariable.new
flg = true
3.times {
Thread.start {
mutex.synchronize {
puts "a1"
while (flg)
cv.wai......t(mutex)
end
puts "a2"
}
}
}
Thread.start {
mutex.synchronize {
flg = false
cv.broadcast
}
}
sleep 1
# => a1
# => a1
# => a1
# => a2
# => a2
# => a2
//}... -
Time
. at(seconds , xseconds , unit) -> Time (6502.0) -
unit に応じて seconds + xseconds ミリ秒などの時刻を表す Time オブジェクトを返します。
...unit に応じて seconds + xseconds ミリ秒などの時刻を表す Time オブジェクトを返します。
@param seconds 起算時からの経過秒数を表わす値をInteger、 Float、 Rational、または他のNumericで指定します。
@param xseconds unit に対応するミリ秒......m unit :millisecond, :usec, :microsecond, :nsec, :nanosecond のいずれかを指定します。
//emlist[][ruby]{
Time.at(946684800, 123.456789, :millisecond).nsec # => 123456789
Time.at(946684800, 123456.789, :usec).nsec # => 123456789
Time.at(946684800, 123456.789, :microsecond).nsec......# => 123456789
Time.at(946684800, 123456789, :nsec).nsec # => 123456789
//}......aram unit :millisecond, :usec, :microsecond, :nsec, :nanosecond のいずれかを指定します。
@param in "+HH:MM" や "-HH:MM" のような形式の文字列か
数値でタイムゾーンを指定します。
//emlist[][ruby]{
Time.at(946684800, 123.456789, :millisecond).nsec # =>......123456789
Time.at(946684800, 123456.789, :usec).nsec # => 123456789
Time.at(946684800, 123456.789, :microsecond).nsec # => 123456789
Time.at(946684800, 123456789, :nsec).nsec # => 123456789
//}......it :millisecond, :usec, :microsecond, :nsec, :nanosecond のいずれかを指定します。
@param in "+HH:MM" や "-HH:MM" のような形式の文字列か
"UTC" かミリタリータイムゾーンの文字列または
数値でタイムゾーンを指定します。
//emli......st[][ruby]{
Time.at(946684800, 123.456789, :millisecond).nsec # => 123456789
Time.at(946684800, 123456.789, :usec).nsec # => 123456789
Time.at(946684800, 123456.789, :microsecond).nsec # => 123456789
Time.at(946684800, 123456789, :nsec).nsec # => 123456789
//}... -
Time
. at(seconds , xseconds , unit , in:) -> Time (6502.0) -
unit に応じて seconds + xseconds ミリ秒などの時刻を表す Time オブジェクトを返します。
...unit に応じて seconds + xseconds ミリ秒などの時刻を表す Time オブジェクトを返します。
@param seconds 起算時からの経過秒数を表わす値をInteger、 Float、 Rational、または他のNumericで指定します。
@param xseconds unit に対応するミリ秒......aram unit :millisecond, :usec, :microsecond, :nsec, :nanosecond のいずれかを指定します。
@param in "+HH:MM" や "-HH:MM" のような形式の文字列か
数値でタイムゾーンを指定します。
//emlist[][ruby]{
Time.at(946684800, 123.456789, :millisecond).nsec # =>......123456789
Time.at(946684800, 123456.789, :usec).nsec # => 123456789
Time.at(946684800, 123456.789, :microsecond).nsec # => 123456789
Time.at(946684800, 123456789, :nsec).nsec # => 123456789
//}......it :millisecond, :usec, :microsecond, :nsec, :nanosecond のいずれかを指定します。
@param in "+HH:MM" や "-HH:MM" のような形式の文字列か
"UTC" かミリタリータイムゾーンの文字列または
数値でタイムゾーンを指定します。
//emli......st[][ruby]{
Time.at(946684800, 123.456789, :millisecond).nsec # => 123456789
Time.at(946684800, 123456.789, :usec).nsec # => 123456789
Time.at(946684800, 123456.789, :microsecond).nsec # => 123456789
Time.at(946684800, 123456789, :nsec).nsec # => 123456789
//}...