クラス
- IO (2)
- Socket (1)
-
Thread
:: ConditionVariable (3) -
Thread
:: Queue (1) - ThreadsWait (7)
モジュール
-
Sync
_ m (2)
キーワード
-
all
_ waits (1) - broadcast (1)
-
connect
_ nonblock (1) - empty? (1)
- finished? (1)
- join (1)
-
join
_ nowait (1) -
next
_ wait (1) -
num
_ waiting (1) -
read
_ nonblock (1) - signal (1)
-
sync
_ upgrade _ waiting (1) -
sync
_ waiting (1) - threads (1)
-
wait
_ readable (1)
検索結果
先頭5件
-
Thread
:: ConditionVariable # wait(mutex , timeout = nil) -> self (63307.0) -
mutex のロックを解放し、カレントスレッドを停止します。 Thread::ConditionVariable#signalまたは、 Thread::ConditionVariable#broadcastで送られたシグナルを 受け取ると、mutexのロックを取得し、実行状態となります。
mutex のロックを解放し、カレントスレッドを停止します。
Thread::ConditionVariable#signalまたは、
Thread::ConditionVariable#broadcastで送られたシグナルを
受け取ると、mutexのロックを取得し、実行状態となります。
@param mutex Thread::Mutex オブジェクトを指定します。
@param timeout スリープする秒数を指定します。この場合はシグナルを受け取
らなかった場合でも指定した秒数が経過するとスリープを終了
します。省略する... -
ThreadsWait
# next _ wait(nonblock = nil) -> Thread (36625.0) -
指定したスレッドのどれかが終了するまで待ちます。
指定したスレッドのどれかが終了するまで待ちます。
@param nonblock true を与えると、キューが空の時、例外 ThreadsWait::ErrNoFinishedThread が発生します。
@raise ErrNoWaitingThread 終了をまつスレッドが存在しない時、発生します。
@raise ErrNoFinishedThread nonblock がtrue でかつ、キューが空の時、発生します。
#使用例
require 'thwait'
threads = []
2.times {|i|
threads << Thread.n... -
ThreadsWait
# join _ nowait(*threads) -> () (36604.0) -
終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。 しかし、実際には終了をまちません。
終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。
しかし、実際には終了をまちません。
@param threads 複数スレッドの終了を待つスレッドに指定されたthreadsを加えます。
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new
p thall.threads #=> []
thall.join_nowait(*thr... -
ThreadsWait
# all _ waits -> () (36304.0) -
指定されたスレッドすべてが終了するまで待ちます。 ブロックが与えられた場合、スレッド終了時にブロックを評価します。
指定されたスレッドすべてが終了するまで待ちます。
ブロックが与えられた場合、スレッド終了時にブロックを評価します。
使用例
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new(*threads)
thall.all_waits{|th|
printf("end %s\n", th.inspect)
}
# 出力例
#=> #<Thread... -
ThreadsWait
# threads -> Array (36304.0) -
同期されるスレッドの一覧を配列で返します。
同期されるスレッドの一覧を配列で返します。
使用例
require 'thwait'
threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new(*threads)
p thall.threads
#=> [#<Thread:0x21750 sleep>, #<Thread:0x216c4 sleep>, #<Thread:0x21638 sleep>] -
IO
# wait _ readable(timeout = nil) -> bool | self | nil (27628.0) -
self が読み込み可能になるまでブロックし、読み込み可能になったら 真値を返します。タイムアウト、もしくはEOFで それ以上読みこめない場合は偽の値を返します。
self が読み込み可能になるまでブロックし、読み込み可能になったら
真値を返します。タイムアウト、もしくはEOFで
それ以上読みこめない場合は偽の値を返します。
より詳しくは、一度ブロックしてから読み込み可能になった場合には
selfを返します。
内部のバッファにデータがある場合には
ブロックせずに true を返します。
内部のバッファとはRubyの処理系が保持管理している
バッファのことです。
つまり、読み込み可能である場合にはtrueを返す場合と
selfを返す場合があることに注意してください。
timeout を指定した場合は、指定秒数経過するまでブロックし、タ
イムアウトし... -
Thread
:: Queue # num _ waiting -> Integer (27304.0) -
キューを待っているスレッドの数を返します。
キューを待っているスレッドの数を返します。
//emlist[例][ruby]{
require 'thread'
q = SizedQueue.new(1)
q.push(1)
t = Thread.new { q.push(2) }
sleep 0.05 until t.stop?
q.num_waiting # => 1
q.pop
t.join
//} -
Sync
_ m # sync _ upgrade _ waiting -> [Thread] (18604.0) -
@todo
@todo -
Sync
_ m # sync _ waiting -> [Thread] (18604.0) -
@todo
@todo -
IO
# read _ nonblock(maxlen , outbuf = nil , exception: true) -> String | Symbol | nil (18481.0) -
IO をノンブロッキングモードに設定し、 その後で read(2) システムコールにより 長さ maxlen を上限として読み込み、文字列として返します。 EAGAIN, EINTR などは Errno::EXXX 例外として呼出元に報告されます。
IO をノンブロッキングモードに設定し、
その後で read(2) システムコールにより
長さ maxlen を上限として読み込み、文字列として返します。
EAGAIN, EINTR などは Errno::EXXX 例外として呼出元に報告されます。
発生した例外 がErrno::EAGAIN、 Errno::EWOULDBLOCK である場合は、
その例外オブジェクトに IO::WaitReadable が Object#extend
されます。
なお、バッファが空でない場合は、read_nonblock はバッファから読み込みます。この場合、read(2) システムコールは呼ばれません... -
ThreadsWait
# join(*threads) -> () (18304.0) -
終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。
終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。
@param threads 複数スレッドの終了を待つスレッドに指定されたthreadsを加えます。
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new
p thall.threads #=> []
thall.join(*threads)
p thall.threads
... -
ThreadsWait
# empty? -> bool (18004.0) -
同期されるスレッドが存在するならば true をかえします。
同期されるスレッドが存在するならば true をかえします。
使用例
require 'thwait'
threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new
p thall.threads.empty? #=> true
thall.join(*threads)
p thall.threads.empty? #=> false -
ThreadsWait
# finished? -> bool (18004.0) -
すでに終了したスレッドが存在すれば true を返します。
すでに終了したスレッドが存在すれば true を返します。
使用例
require 'thwait'
threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new(*threads)
p thall.finished? #=> false
sleep 3
p thall.finished? #=> true -
Thread
:: ConditionVariable # broadcast -> self (9070.0) -
状態変数を待っているスレッドをすべて再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。
状態変数を待っているスレッドをすべて再開します。再開された
スレッドは Thread::ConditionVariable#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 (9070.0) -
状態変数を待っているスレッドを1つ再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。
状態変数を待っているスレッドを1つ再開します。再開された
スレッドは Thread::ConditionVariable#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)
... -
Socket
# connect _ nonblock(server _ sockaddr) -> 0 (40.0) -
ソケットをノンブロッキングモードに設定した後、 connect(2) を呼び出します。
ソケットをノンブロッキングモードに設定した後、
connect(2) を呼び出します。
引数、返り値は Socket#connect と同じです。
connect が EINPROGRESS エラーを報告した場合、その例外(Errno::EINPROGRESS)
には IO::WaitWritable が Object#extend されます。
これを connect_nonblock をリトライするために使うことができます。
# Pull down Google's web page
require 'socket'
include Socket::Constants
...