別のキーワード
クラス
- File (11)
-
File
:: Stat (22) - IO (22)
- Mutex (2)
- Pathname (11)
- SignalException (22)
- Thread (172)
-
Thread
:: ConditionVariable (22) -
Thread
:: Mutex (9) -
Thread
:: Queue (11) - ThreadGroup (22)
- ThreadsWait (42)
キーワード
- <=> (11)
-
abort
_ on _ exception (11) - add (11)
-
all
_ waits (6) - backtrace (11)
-
backtrace
_ locations (22) - birthtime (11)
- broadcast (11)
- ctime (11)
- empty? (6)
- enclose (11)
- eof (11)
- eof? (11)
- exit (11)
- finished? (6)
- flock (11)
- join (28)
-
join
_ nowait (6) - kill (11)
-
next
_ wait (6) -
num
_ waiting (11) - priority (11)
- raise (11)
- run (11)
-
safe
_ level (7) - signal (11)
- signm (11)
- signo (11)
- status (11)
- terminate (11)
- threads (6)
- value (11)
- wakeup (11)
検索結果
先頭5件
-
Mutex
# sleep(timeout = nil) -> Integer (18226.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 (18226.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
//}... -
File
:: Stat # <=>(o) -> Integer | nil (6107.0) -
ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。
...fp1 = Tempfile.open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"
p File::Stat.new(fp1.path) <=> File::Stat.new(fp2.path) #=> -1
p File::Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p File::Stat.new(fp1.path) <=> fp2.path #=> nil
//}... -
ThreadsWait
# all _ waits -> () (167.0) -
指定されたスレッドすべてが終了するまで待ちます。 ブロックが与えられた場合、スレッド終了時にブロックを評価します。
...{ sleep 1; p Thread.current }
}
thall = ThreadsWait.new(*threads)
thall.all_waits{|th|
printf("end %s\n", th.inspect)
}
# 出力例
#=> #<Thread:0x214bc run>
#=> #<Thread:0x21548 run>
#=> #<Thread:0x215d4 run>
#=> #<Thread:0x21660 run>
#=> #<Thread:0x21430 run>
#=> e......nd #<Thread:0x214bc dead>
#=> end #<Thread:0x21548 dead>
#=> end #<Thread:0x215d4 dead>
#=> end #<Thread:0x21660 dead>
#=> end #<Thread:0x21430 dead>... -
ThreadsWait
# join _ nowait(*threads) -> () (143.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 (135.0) -
生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず れかで返します。正常終了したスレッドに対して false、例外によ り終了したスレッドに対して nil を返します。
...生きているスレッドの状態を文字列 "run"、"sleep", "aborting" のいず
れかで返します。正常終了したスレッドに対して false、例外によ
り終了したスレッドに対して nil を返します。
Thread#alive? が真を返すなら、このメソッドも......d.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?... -
File
# flock(operation) -> 0 | false (125.0) -
ファイルをロックします。
...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"
# => locked by process1
# unlock... -
ThreadGroup
# add(thread) -> self (125.0) -
スレッド thread が属するグループを自身に変更します。
...}"
# => 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 group now #{ThreadGroup::Default.list}"
# => Initi......al group now [#<Thread:0x3039168 run>, #<Thread:0x50beed0 run>]
puts "tg group now #{tg.list}"
# => tg group now [#<Thread:0x50bef60 run>]
//}... -
ThreadsWait
# threads -> Array (125.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 (119.0) -
作成された時刻を返します。
...file", "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("testfile").mtime #=> 2014-02-24 11:19:27 +0900
File.stat("testfile").ctime #=> 2014-02-24 1......1:19:37 +0900
File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900
//}... -
Thread
# join -> self (119.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 (119.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}...