るりまサーチ

最速Rubyリファレンスマニュアル検索!
78件ヒット [1-78件を表示] (0.082秒)

別のキーワード

  1. drb thread
  2. thread join
  3. thread kill
  4. thread exit
  5. etc sc_thread_cputime

ライブラリ

クラス

キーワード

検索結果

Thread::Queue#close -> self (21194.0)

キューを close します。close 済みのキューを再度 open することはできません。

...キューを close します。close 済みのキューを再度 open することはできません。

close
後は以下のように動作します。

* Thread::Queue#closed? は true を返します
* Thread::Queue#close は無視されます
* Thread::Queue#enq/push/<< は ClosedQueueError...
...を発生します
* Thread::Queue#empty? が false を返す場合は Thread::Queue#deq/pop/shift は通常通りオブジェクトを返します

また、ClosedQueueError は StopIteration を継承しているため、
close
する事でループから脱出する事もできます。

例:...
...q = Queue.new
Thread.new{
while e = q.deq # wait for nil to break loop
# ...
end
}
q.close...

Thread::SizedQueue#close -> self (21174.0)

キューを close します。詳しくは Thread::Queue#close を参照してください。

...ーを close します。詳しくは Thread::Queue#close を参照してください。

Thread
::Queue とはキューにオブジェクトを追加するスレッドの動作が
異なります。キューにオブジェクトを追加するスレッドを待機している場合は
Close
dQueueErr...
...or が発生して中断されます。

//emlist[例][ruby]{
q = SizedQueue.new(4)

[:resource1, :resource2, :resource3, nil].each { |r| q.push(r) }

q.closed? # => false
q.close
q.closed? # => true
//}

@see Thread::Queue#close...

ThreadGroup#enclose -> self (9131.0)

自身への ThreadGroup#add によるスレッドの追加・削除を禁止します。 enclose された ThreadGroup に追加や削除を行うと例外 ThreadError が発生します。

...自身への ThreadGroup#add によるスレッドの追加・削除を禁止します。
enclose された ThreadGroup に追加や削除を行うと例外 ThreadError が発生します。

ただし、Thread.new によるスレッドの追加は禁止されません。enclose されたスレッ...
...

追加の例:

thg = ThreadGroup.new.enclose
thg.add Thread.new {}

=> -:2:in `add': can't move to the enclosed thread group (ThreadError)

削除の例:

thg1 = ThreadGroup.new
thg2 = ThreadGroup.new

th = Thread.new {sleep 1}

thg1.add th
thg1.enclose
thg2.add th

=> -:8:i...
...n `add': can't move from the enclosed thread group (ThreadError)...

Thread::Queue#closed? -> bool (9123.0)

キューが close されている時に true を返します。

...キューが close されている時に true を返します。

//emlist[例][ruby]{
q = Queue.new

[:resource1, :resource2, :resource3, nil].each { |r| q.push(r) }

q.closed? # => false
q.close
q.closed? # => true
//}...

ThreadGroup#enclosed? -> bool (9107.0)

自身が enclose されているなら true を返します。そうでないなら false を返します。デフォルトは false です。

...nclose されているなら true を返します。そうでないなら false を返します。デフォルトは false です。

freeze された ThreadGroup には Thread の追加/削除ができませんが、enclosed? は false を返します。

thg = ThreadGroup.new
p thg.enclose...
...d? # => false
thg.enclose
p thg.enclosed? # => true

thg = ThreadGroup.new
p thg.enclosed? # => false
thg.freeze
p thg.enclosed? # => false

@see ThreadGroup#enclose...

絞り込み条件を変える

IO#eof -> bool (25.0)

ストリームがファイルの終端に達した場合、true を返します。そうでない場合、false を返します。

...ムであった場合、相手がデータを送るか close するまでブロックします。

r, w = IO.pipe
Thread
.new { sleep 10; w.close }
r.eof? #=> 10秒ブロックしてから true を返す。

r, w = IO.pipe
Thread
.new { sleep 10; w.puts "a" }
r.eof? #=> 10秒ブロ...

IO#eof? -> bool (25.0)

ストリームがファイルの終端に達した場合、true を返します。そうでない場合、false を返します。

...ムであった場合、相手がデータを送るか close するまでブロックします。

r, w = IO.pipe
Thread
.new { sleep 10; w.close }
r.eof? #=> 10秒ブロックしてから true を返す。

r, w = IO.pipe
Thread
.new { sleep 10; w.puts "a" }
r.eof? #=> 10秒ブロ...