38件ヒット
[1-38件を表示]
(0.033秒)
別のキーワード
種類
- インスタンスメソッド (29)
- クラス (9)
クラス
- Mutex (2)
-
Thread
:: ConditionVariable (18) -
Thread
:: Mutex (9)
キーワード
- ConditionVariable (9)
- broadcast (9)
- signal (9)
検索結果
先頭5件
-
Mutex
# synchronize { . . . } -> object (18115.0) -
mutex をロックし、ブロックを実行します。実行後に必ず mutex のロックを解放します。
...ロックを実行します。実行後に必ず mutex のロックを解放します。
ブロックが最後に評価した値を返します。
@raise ThreadError self 既にカレントスレッドにロックされている場合に発
生します。
ま......た、Signal.#trap に指定したハンドラ内で実行
した場合に発生します。
//emlist[例][ruby]{
m = Mutex.new
result = m.synchronize do
m.locked? # => true
# critical part
"result"
end
m.locked? # => false
result # => "result"
//}... -
Thread
:: Mutex # synchronize { . . . } -> object (18115.0) -
mutex をロックし、ブロックを実行します。実行後に必ず mutex のロックを解放します。
...ロックを実行します。実行後に必ず mutex のロックを解放します。
ブロックが最後に評価した値を返します。
@raise ThreadError self 既にカレントスレッドにロックされている場合に発
生します。
ま......た、Signal.#trap に指定したハンドラ内で実行
した場合に発生します。
//emlist[例][ruby]{
m = Mutex.new
result = m.synchronize do
m.locked? # => true
# critical part
"result"
end
m.locked? # => false
result # => "result"
//}... -
Thread
:: ConditionVariable (116.0) -
スレッドの同期機構の一つである状態変数を実現するクラスです。
...onVariable.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......= Mutex.new
@q = []
end
def count
@q.size
end
def enq(v)
@mutex.synchronize{
@full.wait(@mutex) if count == @max
@q.push v
@empty.signal if count == 1
}
end
def deq
@mutex.synchronize{
@empty.wait(@mutex) if co... -
Thread
:: ConditionVariable # broadcast -> self (20.0) -
状態変数を待っているスレッドをすべて再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。
...Variable#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.wait(mutex)... -
Thread
:: ConditionVariable # signal -> self (20.0) -
状態変数を待っているスレッドを1つ再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。
...Variable#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.wait(mutex)...