るりまサーチ

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

別のキーワード

  1. drb thread
  2. thread exit
  3. thread join
  4. thread kill
  5. tracer get_thread_no

ライブラリ

モジュール

キーワード

検索結果

<< < 1 2 3 4 ... > >>

Thread::Queue#empty? -> bool (11007.0)

キューが空の時、真を返します。

...キューが空の時、真を返します。

//emlist[例][ruby]{
require 'thread'
q = Queue.new
q.empty? # => true
q.push(:resource)
q.empty? # => false
//}...

Thread::Queue#length -> Integer (11007.0)

キューの長さを返します。

...キューの長さを返します。

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

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

q.length # => 4
//}...

Thread::Queue#size -> Integer (11007.0)

キューの長さを返します。

...キューの長さを返します。

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

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

q.length # => 4
//}...

Thread::SizedQueue#max=(n) (11007.0)

キューの最大サイズを設定します。

...キューの最大サイズを設定します。

@param n キューの最大サイズを指定します。

//emlist[例][ruby]{
require 'thread'
q = SizedQueue.new(4)
q.max # => 4
q.max = 5
q.max # => 5
//}...

Thread::Queue#<<(value) -> () (11001.0)

キューの値を追加します。待っているスレッドがいれば実行を再開 させます。返り値は不定です。

キューの値を追加します。待っているスレッドがいれば実行を再開
させます。返り値は不定です。

絞り込み条件を変える

Thread::Queue#enq(value) -> () (11001.0)

キューの値を追加します。待っているスレッドがいれば実行を再開 させます。返り値は不定です。

キューの値を追加します。待っているスレッドがいれば実行を再開
させます。返り値は不定です。

Thread::Queue#push(value) -> () (11001.0)

キューの値を追加します。待っているスレッドがいれば実行を再開 させます。返り値は不定です。

キューの値を追加します。待っているスレッドがいれば実行を再開
させます。返り値は不定です。

Thread::SizedQueue#max -> Integer (11001.0)

キューの最大サイズを返します。

キューの最大サイズを返します。

//emlist[例][ruby]{
q = SizedQueue.new(4)
q.max # => 4
//}

Thread#backtrace_locations(range) -> [Thread::Backtrace::Location] | nil (9149.0)

スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。

...スレッドの現在のバックトレースを Thread::Backtrace::Location の配
列で返します。

引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。

@param start 開始フレームの位置を数値で指定します...
...似ていますが、本メソッドは self に限定
した情報を返します。

//emlist[例][ruby]{
thread
= Thread.new { sleep 1 }
thread
.run
thread
.backtrace_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}

@see Thread::Backtrace::Location...

Thread#backtrace_locations(start = 0, length = nil) -> [Thread::Backtrace::Location] | nil (9149.0)

スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。

...スレッドの現在のバックトレースを Thread::Backtrace::Location の配
列で返します。

引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。

@param start 開始フレームの位置を数値で指定します...
...似ていますが、本メソッドは self に限定
した情報を返します。

//emlist[例][ruby]{
thread
= Thread.new { sleep 1 }
thread
.run
thread
.backtrace_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}

@see Thread::Backtrace::Location...

絞り込み条件を変える

Thread#[](name) -> object | nil (9133.0)

name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。

...emlist[例][ruby]{
[
Thread
.new { Thread.current["name"] = "A" },
Thread
.new { Thread.current[:name] = "B" },
Thread
.new { Thread.current["name"] = "C" }
].each do |th|
th.join
puts "#{th.inspect}: #{th[:name]}"
end

# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 d...
...0000002a54130 dead>: C
//}

Thread
#[] と Thread#[]= を用いたスレッド固有の変数は
Fiber を切り替えると異なる変数を返す事に注意してください。

//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
Thread
.current[:name] = newvalu...
...ume
p Thread.current[:name]
# => nil if fiber-local
# => 2 if thread-local (The value 2 is leaked to outside of meth method.)
//}

Fiber を切り替えても同じ変数を返したい場合は
Thread
#thread_variable_get と Thread#thread_variable_set
を使用してください。

@see Thread#fet...

ThreadsWait#threads -> Array (9131.0)

同期されるスレッドの一覧を配列で返します。

...ドの一覧を配列で返します。

使用例
require 'thwait'

thread
s = []
3.times {|i|
thread
s << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new(*threads)
p thall.threads
#=> [#<Thread:0x21750 sleep>, #<Thread:0x216c4 sleep>, #<Thread:0x21638 sleep>]...

Thread#[](name) -> object | nil (9127.0)

name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。

...emlist[例][ruby]{
[
Thread
.new { Thread.current["name"] = "A" },
Thread
.new { Thread.current[:name] = "B" },
Thread
.new { Thread.current["name"] = "C" }
].each do |th|
th.join
puts "#{th.inspect}: #{th[:name]}"
end

# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 d...
...0000002a54130 dead>: C
//}

Thread
#[] と Thread#[]= を用いたスレッド固有の変数は
Fiber を切り替えると異なる変数を返す事に注意してください。

//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
Thread
.current[:name] = newvalu...
....resume
p Thread.current[:name]
# => nil if fiber-local
# => 2 if thread-local (The value 2 is leaked to outside of meth method.)
//}

Fiber を切り替えても同じ変数を返したい場合は
Thread
#thread_variable_get と Thread#thread_variable_set
を使用してください。

Thread
#[]=...

Thread#group -> ThreadGroup (9107.0)

スレッドが属している ThreadGroup オブジェクトを返します。

...スレッドが属している ThreadGroup オブジェクトを返します。

p Thread.current.group == ThreadGroup::Default
# => true...

Thread#status -> String | false | nil (9067.0)

生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず れかで返します。正常終了したスレッドに対して false、例外によ り終了したスレッドに対して nil を返します。

...て nil を返します。

Thread
#alive? が真を返すなら、このメソッドも真です。

例:
a = Thread.new { raise("die now") }
b = Thread.new { Thread.stop }
c = Thread.new { Thread.exit }
d = Thread.new { sleep }
d.kill #=> #<Thread:0x401b3678 aborting>
a...
....status #=> nil
b.status #=> "sleep"
c.status #=> false
d.status #=> "aborting"
Thread
.current.status #=> "run"

@see Thread#alive?, Thread#stop?...

絞り込み条件を変える

Thread#report_on_exception -> bool (9055.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...ルトはスレッド作成時の Thread.report_on_exception です。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。

//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception...
...true
a.run
# => #<Thread:0x00007fc3f48c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b....
...report_on_exception = false
b.run # => #<Thread:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...

Thread#report_on_exception=(newstate) (9055.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...ルトはスレッド作成時の Thread.report_on_exception です。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。

//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception...
...true
a.run
# => #<Thread:0x00007fc3f48c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b....
...report_on_exception = false
b.run # => #<Thread:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...
<< < 1 2 3 4 ... > >>