るりまサーチ

最速Rubyリファレンスマニュアル検索!
799件ヒット [1-100件を表示] (0.078秒)
トップページ > クエリ:a[x] > クエリ:sleep[x]

別のキーワード

  1. _builtin to_a
  2. matrix to_a
  3. to_a
  4. dbm to_a
  5. argf.class to_a

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Thread::Mutex#sleep(timeout = nil) -> Integer (21125.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 自身がカレントスレ...

void rb_thread_sleep(int sec) (12200.0)

void rb_thread_sleep_forever(void) (12200.0)

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

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

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

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

@param start 開始フレームの位置を数値で指定します。

@param length 取得する...
...@param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。

Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。

//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.run
thread.backtrac...
...e_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 (9412.0)

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

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

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

@param start 開始フレームの位置を数値で指定します。

@param length 取得する...
...@param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。

Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。

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

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

絞り込み条件を変える

ThreadGroup#add(thread) -> self (9218.0)

スレッド thread が属するグループを自身に変更します。

...ッド thread が属するグループを自身に変更します。

@param thread 自身に加えたいスレッドを指定します。

@raise ThreadError 自身が freeze されているか enclose されている場合に、発生します。また引数 thread が属する ThreadGroup が fre...
..."Initial group is #{ThreadGroup::Default.list}"
# => Initial group is [#<Thread:0x4a49168 run>]

tg = ThreadGroup.new
t1 = Thread.new { sleep }
t2 = Thread.new { sleep }
puts "t1 is #{t1}" # => t1 is #<Thread:0x50bef60>
puts "t2 is #{t2}" # => t2 is #<Thread:0x50beed0>
tg.add(t1)
puts "Initial grou...
...p now #{ThreadGroup::Default.list}"
# => Initial group now [#<Thread:0x3039168 run>, #<Thread:0x50beed0 run>]
puts "tg group now #{tg.list}"
# => tg group now [#<Thread:0x50bef60 run>]
//}...

Thread#backtrace -> [String] | nil (9212.0)

スレッドの現在のバックトレースを返します。

...y]{
class C1
def m1
sleep
5
end
def m2
m1
end
end

th = Thread.new {C1.new.m2; Thread.stop}
th.backtrace
# => [
# [0] "(irb):3:in `sleep'",
# [1] "(irb):3:in `m1'",
# [2] "(irb):6:in `m2'",
# [3] "(irb):10:in `block in irb_binding'"
# ]

th.kill
th.backtrace...

Thread::ConditionVariable#broadcast -> self (9154.0)

状態変数を待っているスレッドをすべて再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。

...read::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.wai...
...t(mutex)
end
puts "a2"
}
}
}

Thread.start {
mutex.synchronize {
flg = false
cv.broadcast
}
}

sleep
1

# => a1
# => a1
# => a1
# => a2
# => a2
# => a2
//}...

ThreadsWait#threads -> Array (9124.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>]...
<< 1 2 3 ... > >>