るりまサーチ

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

別のキーワード

  1. _builtin sleep
  2. kernel sleep
  3. mutex sleep
  4. sleep _builtin

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

Mutex#sleep(timeout = nil) -> Integer (18126.0)

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

...グナルを受信した場合などに実行が再
開(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
//}...

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

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

...グナルを受信した場合などに実行が再
開(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
//}...

ThreadsWait#join_nowait(*threads) -> () (43.0)

終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。 しかし、実際には終了をまちません。

...eads << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new
p thall.threads #=> []
thall.join_nowait(*threads)
p thall.threads #=> [#<Thread:0x21638 sleep>, #<Thread:0x215ac sleep>, #<Thread:0x21520 sleep>, #<Thread:0x21494 sleep>, #<Thread:0x21408 sleep>]
# 実際には...
...終了を待っていない。sleep している。...

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

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

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

Thread#alive? が真を返すなら、このメソッドも...
...= 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"...

File#flock(operation) -> 0 | false (25.0)

ファイルをロックします。

...", "r")
f.flock(File::LOCK_SH)
puts "locked by process2"
sleep
5
puts "unlocked by process2"
}

sleep
5

f.flock(File::LOCK_UN)
puts "unlocked by process1"
sleep
1 # <- 子プロセスが確実に先にロックするための sleep
f.flock(File::LOCK_EX)
puts "re-locked by process1"

# => l...

絞り込み条件を変える

ThreadsWait#threads -> Array (25.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>]...

File::Stat#birthtime -> Time (19.0)

作成された時刻を返します。

...のような birthtime のない環境で発生します。

//emlist[][ruby]{
File.write("testfile", "foo")
sleep
10
File.write("testfile", "bar")
sleep
10
File.chmod(0644, "testfile")
sleep
10
File.read("testfile")
File.stat("testfile").birthtime #=> 2014-02-24 11:19:17 +0900
File.stat("testfil...

Thread#join -> self (19.0)

スレッド self の実行が終了するまで、カレントスレッドを停止し ます。self が例外により終了していれば、その例外がカレントス レッドに対して発生します。

...

以下は、生成したすべてのスレッドの終了を待つ例です。

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

threads.each {|t| t.join}...

Thread#join(limit) -> self | nil (19.0)

スレッド self の実行が終了するまで、カレントスレッドを停止し ます。self が例外により終了していれば、その例外がカレントス レッドに対して発生します。

...

以下は、生成したすべてのスレッドの終了を待つ例です。

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

threads.each {|t| t.join}...

Thread#value -> object (19.0)

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

...果を出力する例です。

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

threads.each {|t| p t.value}

最後の行で、待ち合わせを行ってい...

絞り込み条件を変える

IO#eof -> bool (13.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秒ブロックしてから false を返す。

r,...
<< 1 2 3 ... > >>