るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dh p=
  5. rsa p

ライブラリ

モジュール

キーワード

検索結果

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

ThreadsWait#threads -> Array (9143.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 (9139.0)

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

...@param name スレッド固有データのキーを文字列か Symbol で指定します。

//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
p
uts "#{th.inspe...
...ct}: #{th[:name]}"
end

# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 dead>: B
# => #<Thread:0x00000002a54130 dead>: C
//}

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

//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
Thread
.current[:name] = newvalue
yield
ensure
Thread
.current[:name] = oldvalue
end
end
//}

この関数に与えるブロックがFiberを切り替える場合は動的スコープとしては
...

ThreadsWait#empty? -> bool (9131.0)

同期されるスレッドが存在するならば true をかえします。

...ッドが存在するならば true をかえします。

使用例
require 'thwait'

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

thall = ThreadsWait.new
p
thall.threads.empty? #=> true
thall.join(*threads)
p
thall.threads.empty? #=> false...

Thread#raise(error_type, message, traceback) -> () (9119.0)

自身が表すスレッドで強制的に例外を発生させます。

...す。

@param error_type Kernel.#raise を参照してください。

@param message Kernel.#raise を参照してください。

@param traceback Kernel.#raise を参照してください。

Thread
.new {
sleep 1
Thread
.main.raise "foobar"
}

begin
sleep
rescue
p
$!, $@...

Thread::Backtrace::Location#inspect -> String (9117.0)

Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文 字列に変換したオブジェクトを返します。

...
Thread
::Backtrace::Location#to_s の結果を人間が読みやすいような文
字列に変換したオブジェクトを返します。

//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).loc...
...ations.map do |call|
p
uts call.inspect
end

# => "path/to/foo.rb:5:in `initialize'"
# "path/to/foo.rb:9:in `new'"
# "path/to/foo.rb:9:in `<main>'"
//}...

絞り込み条件を変える

Thread::Backtrace::Location#path -> String (9113.0)

self が表すフレームのファイル名を返します。

...self が表すフレームのファイル名を返します。

例: Thread::Backtrace::Location の例1を用いた例

//emlist[][ruby]{
loc = c(0..1).first
loc.path # => "caller_locations.rb"
//}

@see Thread::Backtrace::Location#absolute_path...

Thread::Backtrace::Location#absolute_path -> String (9107.0)

self が表すフレームの絶対パスを返します。

...][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
p
uts call.absolute_path
end

# => /path/to/foo.rb
# /path/to/foo.rb
# /path/to/foo.rb
//}

@see Thread::Backtrace::Location#path...

Thread::Mutex#sleep(timeout = nil) -> Integer (9107.0)

与えられた秒数の間ロックを解除してスリープして、実行後にまたロックします。

...リープして、実行後にまたロックします。

@param timeout スリープする秒数を指定します。省略するとスリープし続けます。

@return スリープしていた秒数を返します。

@raise ThreadError 自身がカレントスレッドによってロックさ...
...グナルを受信した場合などに実行が再
開(spurious wakeup)される場合がある点に注意してください。

//emlist[例][ruby]{
m = Mutex.new
th = Thread.new do
m.lock
m.sleep(2)
end
th.status # => "run"
sleep 1
th.status # => "sleep"
sleep 1
th.status # => false
//}...
...にまたロックします。

@param timeout スリープする秒数を指定します。省略するとスリープし続けます。

@return タイムアウトした時は nil を、それ以外はスリープしていた秒数を返します。

@raise ThreadError 自身がカレントスレ...

Net::IMAP#client_thread=(th) (9102.0)

このメソッドは obsolete です。使わないでください。

このメソッドは obsolete です。使わないでください。

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

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

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

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

絞り込み条件を変える

Thread::SizedQueue#empty? -> bool (9101.0)

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

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

Thread#value -> object (9053.0)

スレッド self が終了するまで待ち(Thread#join と同じ)、 そのスレッドのブロックが返した値を返します。スレッド実行中に例外が 発生した場合には、その例外を再発生させます。

...ッド self が終了するまで待ち(Thread#join と同じ)、
そのスレッドのブロックが返した値を返します。スレッド実行中に例外が
発生した場合には、その例外を再発生させます。

スレッドが Thread#kill によって終了した場合は、...
...了を待ち結果を出力する例です。

thread
s = []
thread
s.push(Thread.new { n = rand(5); sleep n; n })
thread
s.push(Thread.new { n = rand(5); sleep n; n })
thread
s.push(Thread.new { n = rand(5); sleep n; n })

thread
s.each {|t| p t.value}

最後の行で、待ち合わせ...
...を行っていることがわかりにくいと思うなら以下
のように書くこともできます。

thread
s.each {|t| p t.join.value}...
<< < 1 2 3 4 5 ... > >>