ライブラリ
クラス
- File (11)
-
File
:: Stat (22) - IO (22)
- Mutex (2)
- Pathname (11)
- SignalException (22)
- Thread (205)
-
Thread
:: ConditionVariable (22) -
Thread
:: Mutex (9) -
Thread
:: Queue (11) - ThreadGroup (33)
- ThreadsWait (60)
-
WIN32OLE
_ EVENT (11)
キーワード
- <=> (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 3
. 0 . 0 (4) - Observable (11)
- Telnet (2)
- Thread (11)
- ThreadGroup (11)
-
abort
_ on _ exception (11) - add (11)
-
all
_ waits (18) - backtrace (11)
-
backtrace
_ locations (22) - birthtime (11)
- broadcast (11)
- ctime (11)
- detach (11)
- empty? (6)
- enclose (11)
- eof (11)
- eof? (11)
- exec (44)
- exit (11)
- finished? (6)
- flock (11)
- fork (22)
- join (28)
-
join
_ nowait (6) - kill (11)
- list (11)
- new (17)
-
next
_ wait (6) -
num
_ waiting (11) -
pipeline
_ start (22) - priority (11)
- priority= (11)
- raise (11)
-
rdoc
/ markdown (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 3 feature (11) - run (11)
-
safe
_ level (7) - signal (11)
- signm (11)
- signo (11)
- status (11)
- stop (11)
- terminate (11)
- threads (6)
- timeout (19)
- tsort (11)
- value (11)
- wait (11)
- wait2 (11)
- waitpid (11)
- waitpid2 (11)
- wakeup (11)
- スレッド (11)
- 制御構造 (11)
検索結果
先頭5件
-
Kernel
. # sleep -> Integer (18226.0) -
sec 秒だけプログラムの実行を停止します。
...スレッドからの Thread#run
などで明示的に起こさない限り永久にスリープします。Thread#runを呼ぶとその時点で
sleepの実行が中断されます。
@param sec 停止する秒数を非負の数値で指定します。浮動小数点数も指定できます。......省略された場合、永久にスリープします。
@return 実際に停止していた秒数 (整数に丸められた値) です。
//emlist[例][ruby]{
it = Thread.new do
sleep
puts 'it_end'
end
re = sleep 2.11
puts re
it.run
re2 = sleep 0.76
puts re2
#=> 2
# it_end
# 1
//}... -
Kernel
. # sleep(sec) -> Integer (18226.0) -
sec 秒だけプログラムの実行を停止します。
...スレッドからの Thread#run
などで明示的に起こさない限り永久にスリープします。Thread#runを呼ぶとその時点で
sleepの実行が中断されます。
@param sec 停止する秒数を非負の数値で指定します。浮動小数点数も指定できます。......省略された場合、永久にスリープします。
@return 実際に停止していた秒数 (整数に丸められた値) です。
//emlist[例][ruby]{
it = Thread.new do
sleep
puts 'it_end'
end
re = sleep 2.11
puts re
it.run
re2 = sleep 0.76
puts re2
#=> 2
# it_end
# 1
//}... -
Mutex
# sleep(timeout = nil) -> Integer (18225.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 (18225.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
//}... -
ruby 1
. 6 feature (5286.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...グ修正がメイン
になります。
((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。
== 1.6.8 (2002-12-24) -> stable-snapshot
: 2003-01-22: errno
EAGAIN と EWOULDBLOCK が同じ値の......> ruby 1.6.7 (2002-03-01) [i586-linux]
Errno::EAGAIN
Errno::EWOULDBLOCK
=> ruby 1.6.8 (2002-12-24) [i586-linux]
Errno::EAGAIN
-:2: uninitialized constant EWOULDBLOCK at Errno (NameError)
=> ruby 1.6.8 (2003-02-13) [i586-linux]......02-07-30) [i586-linux]
: 2002-05-20 IO#close
双方向のパイプの dup を close_write するとエラーになっていました。
((<ruby-dev:17155>))
open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end
}
=> ruby 1.6.7 (2002-03-01... -
ruby 1
. 8 . 3 feature (1506.0) -
ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))
...されたクラス/メソッドなど
* [compat]: 変更されたクラス/メソッドなど
* 互換性のある変更
* only backward-compatibility
* 影響の範囲が小さいと思われる変更もこちら
* [change]: 変更されたクラス/メソッドなど(互換......てください。
soap4r-1.5.3がruby-1.8.2、soap4r-1.5.5がruby-1.8.3にbundleされています。
* ((<URL:http://dev.ctor.org/soap4r/wiki/Changes-154>))
* ((<URL:http://dev.ctor.org/soap4r/wiki/Changes-155>))
== 1.8.2 (2004-12-25) -> 1.8.3 (2005-09-21)
=== 2005-09-19
: FileUtils.remove_ent......((<ruby-dev:25430>)) ((<ruby-dev:25443>))
$ ruby -e 'sleep 1; print "hoge"' | ruby-1.8.2 -rio/nonblock -we '
io = IO.open(0)
io.nonblock = true
p io.read(4)'
-e:4:in... -
NEWS for Ruby 3
. 0 . 0 (306.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...mlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end
//}
* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern matching is redesigned. [EXPERIMENTAL]
* `=>` is added. It can be used like a rightward assignment.
17260
* `in......> 0
{b: 0, c: 1} => {b:}
p b #=> 0
//}
//emlist{
# version 3.0
0 in 1 #=> false
# version 2.7
0 in 1 #=> raise NoMatchingPatternError
//}
* Find-pattern is added. [EXPERIMENTAL]
16828
//emlist{
case ["a", 1, "b", "c", 2, "d", "e", "f", 3]
in [*pre, String => x, String => y, *post]
p pr......INE__` in the evaluated code. 4352
* Kernel#lambda now warns if called without a literal block. 15973
* Kernel.sleep invokes the scheduler hook `#kernel_sleep(...)` in a non-blocking execution context. 16786
* Module
* Module#include and Module#prepend now affect classes and modules th... -
File
:: Stat # birthtime -> Time (166.0) -
作成された時刻を返します。
...", "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 11:19......:37 +0900
File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900
//}... -
ThreadGroup
. new -> ThreadGroup (148.0) -
新たな ThreadGroup を生成して返します。
...[例][ruby]{
thread_group = ThreadGroup.new
thread_group.add Thread.new { sleep 0.1; Thread.new { sleep 1 }; sleep 1 }
thread_group.add Thread.new { sleep 2 }
sleep 0.5
thread_group.list # => [#<Thread:0x007fc6f1842d70 sleep>, #<Thread:0x007fc6f1842c80 sleep>, #<Thread:0x007fc6f080dba8 sleep>]
//}... -
ThreadsWait
# join _ nowait(*threads) -> () (142.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 している。... -
File
# flock(operation) -> 0 | false (136.0) -
ファイルをロックします。
...k(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"
# => locked by process......1
# unlocked by process1
# locked by process2
# unlocked by process2
# re-locked by process1
//}... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (136.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...せるタイムアウト
#!/usr/bin/env ruby
require 'timeout'
class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep(30)
}
rescue MYError => err
puts "MYError"
puts err
end
=== 注意
timeout による割り込みは Thread によって実現......ものは実用レベルでは少ないのですが、
Socket などは DNSの名前解決に時間がかかった場合割り込めません
(resolv-replace を使用する必要があります)。
その処理を Ruby で実装しなおすか C 側で Ruby
のスレッドを意識してあげる......e("www.ruby-lang.org")
# (A)
}
ensure
p Time.now - start
end
# 実行例
=> ["helium.ruby-lang.org", [], 2, "210.251.121.214"]
0.689331
/usr/local/lib/ruby/1.6/timeout.rb:37: execution expired (TimeoutError)
from -:6:in `timeout'
from -:6
# get...