るりまサーチ (Ruby 2.1.0)

最速Rubyリファレンスマニュアル検索!
4件ヒット [1-4件を表示] (0.006秒)

別のキーワード

  1. psych alias
  2. alias new
  3. alias anchor
  4. handler alias
  5. alias anchor=

キーワード

検索結果

ConditionVariable (58.0)

Alias of Thread::ConditionVariable

...Alias of Thread::ConditionVariable...

Queue (58.0)

Alias of Thread::Queue

...Alias of Thread::Queue...

SizedQueue (58.0)

Alias of Thread::SizedQueue

...Alias of Thread::SizedQueue...

Thread::ConditionVariable (46.0)

スレッドの同期機構の一つである状態変数を実現するクラスです。

...クラスです。

以下も ConditionVariable を理解するのに参考になります。

https://ruby-doc.com/docs/ProgrammingRuby/html/tut_threads.html#UF

=== Condition Variable とは

あるスレッド A が排他領域で動いていたとします。スレッド A は現在空いてい...
...tex = Mutex.new
cv = ConditionVariable.new

a = Thread.start {
mutex.synchronize {
...
while (条件が満たされない)
cv.wait(mutex)
end
...
}
}

b = Thread.start {
mutex.synchronize {
# 上の...
...@q が空になった場合、
あるいは満タンになった場合に Condition Variable を使って wait しています。

require 'thread'

class
TinyQueue
def initialize(max=2)
@max = max
@full = ConditionVariable.new
@empty = ConditionVariable.new
@mutex =...