るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.005秒)
トップページ > クエリ:deq[x] > 種類:クラス[x]

別のキーワード

  1. _builtin deq
  2. queue deq
  3. sizedqueue deq
  4. thread deq
  5. deq threaderror

ライブラリ

検索結果

Thread::ConditionVariable (13.0)

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

...が空になった場合、
あるいは満タンになった場合に Condition Variable を使って wait しています。

require 'thread'

class
TinyQueue
def initialize(max=2)
@max = max
@full = ConditionVariable.new
@empty = ConditionVariable.new
@mutex = Mut...
...pty.signal if count == 1
}
end

def deq
@mutex.synchronize{
@empty.wait(@mutex) if count == 0
v = @q.shift
@full.signal if count == (@max - 1)
v
}
end

alias send enq
alias recv deq
end

if __FILE__ == $0
q = TinyQueue.new...