18件ヒット
[1-18件を表示]
(0.082秒)
検索結果
-
Thread
:: SizedQueue # max=(n) (26112.0) -
キューの最大サイズを設定します。
...キューの最大サイズを設定します。
@param n キューの最大サイズを指定します。
//emlist[例][ruby]{
q = SizedQueue.new(4)
q.max # => 4
q.max = 5
q.max # => 5
//}... -
Thread
:: ConditionVariable (8060.0) -
スレッドの同期機構の一つである状態変数を実現するクラスです。
...レッド a に対して条件が成立したことを通知します。これが典型的な
使用例です。
mutex = Mutex.new
cv = ConditionVariable.new
a = Thread.start {
mutex.synchronize {
...
while (条件が満たされない)
cv.wait(m......って 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)
@mutex.s......E__ == $0
q = TinyQueue.new(1)
foods = 'Apple Banana Strawberry Udon Rice Milk'.split
l = []
th = Thread.new {
for obj in foods
q.send(obj)
print "sent ", obj, "\n"
end
q.send nil
}
l.push th
th = Thread.new {
while obj = q.recv...