るりまサーチ

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

別のキーワード

  1. socket iff_802_1q_vlan
  2. openssl q=
  3. openssl q
  4. dsa q=
  5. rsa q=

ライブラリ

キーワード

検索結果

Thread::ConditionVariable (13.0)

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

...Variable を使って wait しています。

require 'thread'

class
TinyQueue
def initialize(max=2)
@max = max
@full = ConditionVariable.new
@empty = ConditionVariable.new
@mutex = Mutex.new
@q = []
end

def count
@q.size
end

def enq(v)...
...= @q.shift
@full.signal if count == (@max - 1)
v
}
end

alias send enq
alias recv deq
end

if __FILE__ == $0
q =
TinyQueue.new(1)
foods = 'Apple Banana Strawberry Udon Rice Milk'.split
l = []

th = Thread.new {
for obj in foods
q.se...

Thread::SizedQueue (13.0)

サイズの最大値を指定できる Thread::Queue です。

...することによって、入力される行と出力される行が同じ順序になります。
q =
[] にすると入力と違った順序で行が出力されます。

require 'thread'

q =
SizedQueue.new(1)

th = Thread.start {
while line = q.pop
print line
end
}

wh...

Thread::Queue (7.0)

Queue はスレッド間の FIFO(first in first out) の通信路です。ス レッドが空のキューを読み出そうとすると停止します。キューになんら かの情報が書き込まれると実行は再開されます。

...す。

最大サイズが指定できる Queue のサブクラス Thread::SizedQueue も提供されています。

=== 例

require 'thread'

q =
Queue.new

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|...