別のキーワード
種類
- インスタンスメソッド (203)
- 文書 (44)
- ライブラリ (11)
- モジュール (11)
クラス
-
File
:: Stat (11) - Pathname (11)
- SignalException (22)
- Thread (115)
-
Thread
:: ConditionVariable (22) - ThreadGroup (22)
キーワード
- <=> (11)
-
NEWS for Ruby 2
. 0 . 0 (11) - Observable (11)
- add (11)
-
backtrace
_ locations (22) - broadcast (11)
- ctime (11)
-
drb
/ gw (11) - enclose (11)
- exit (11)
- join (22)
- kill (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 3 feature (11) - run (11)
-
safe
_ level (5) - signal (11)
- signm (11)
- signo (11)
- terminate (11)
- value (11)
- wakeup (11)
- 制御構造 (11)
検索結果
先頭5件
-
Thread
:: ConditionVariable # signal -> self (113.0) -
状態変数を待っているスレッドを1つ再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。
...開します。再開された
スレッドは Thread::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.wait(mutex)
end
puts "a2"
}
}
}
Thread.start {
mutex.synchronize {
flg = false
cv.signal
}
}
sleep 1
# => a1
# => a1
# => a1
# => a2
//}... -
ThreadGroup
# add(thread) -> self (113.0) -
スレッド thread が属するグループを自身に変更します。
...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 group... -
ThreadGroup
# enclose -> self (107.0) -
自身への ThreadGroup#add によるスレッドの追加・削除を禁止します。 enclose された ThreadGroup に追加や削除を行うと例外 ThreadError が発生します。
...ad.new {}
=> -:2:in `add': can't move to the enclosed thread group (ThreadError)
削除の例:
thg1 = ThreadGroup.new
thg2 = ThreadGroup.new
th = Thread.new {sleep 1}
thg1.add th
thg1.enclose
thg2.add th
=> -:8:in `add': can't move from the enclosed thread group (ThreadError)... -
ruby 1
. 8 . 3 feature (36.0) -
ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))
...101 #=> @@foo は Fred クラスのクラス変数ではない。
end
def Fred.foo_foo
class_variable_set(:@@foo, 101) # self が Fred クラス自身であることに注意。クラス変数 @@foo に値をセットする。
end
Fred.foo # メソ......singleton class [ruby] [change]
特異クラスは複製できなくなりました。((<ruby-talk:142749>))
$ ruby-1.8.3 -e 'class << "str"; self end.dup'
-e:1:in `initialize_copy': can't copy singleton class (TypeError)
from -e:1
=== 2005-05-15
: Pathname#unlink [lib] [comp......移行先として
ruby 1.8.3 に IO#((<IO/readpartial>)) が追加されました。
((<ruby-dev:25430>)) ((<ruby-dev:25443>))
$ ruby -e 'sleep 1; print "hoge"' | ruby-1.8.2 -rio/nonblock -we '
io = IO.open(0)... -
Thread
# value -> object (34.0) -
スレッド self が終了するまで待ち(Thread#join と同じ)、 そのスレッドのブロックが返した値を返します。スレッド実行中に例外が 発生した場合には、その例外を再発生させます。
...スレッド self が終了するまで待ち(Thread#join と同じ)、
そのスレッドのブロックが返した値を返します。スレッド実行中に例外が
発生した場合には、その例外を再発生させます。
スレッドが Thread#kill によって終了した場合......果を出力する例です。
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}
最後の行で、待ち合わせを行ってい... -
NEWS for Ruby 2
. 0 . 0 (30.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...たファイルのパスを返します
* Module
* 追加: Module#prepend 指定したモジュールを self の継承チェインの先頭に
「追加する」ことで self の定数、メソッド、モジュール変数を「上書き」します。
* 追加: Module.prepended......* Mutex#lock, Mutex#unlock, Mutex#try_lock, Mutex#synchronize, Mutex#sleep
はトラップハンドラの中では使えなくなりました。そのようなときは ThreadError が発生します
* Mutex#sleep may spurious wakeup. Check after wakeup.
* NilClass
* 追加: N......rivate になりました
* Thread#join, Thread#value
* 上を参照
* Mutex#lock, Mutex#unlock, Mutex#try_lock, Mutex#synchronize, Mutex#sleep
* 上を参照
=== 標準添付ライブラリの更新 (優れたもののみ)
* cgi
* HTML5 用のタグメーカーを追加しま... -
制御構造 (24.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...引数を伴った break により
while 式の戻り値をその値にすることもできます。
==== while 修飾子
//emlist[例][ruby]{
sleep(60) while io_not_ready?
//}
文法:
式 while 式
右辺の式を評価した値が真の間、左辺を繰り返し実行します。......ソッド(イテレータ)を定義する必要があります。
//emlist[][ruby]{
class Array
def each2
i = 0
while i < self.size
yield self[i], self[i+1]
i += 2
end
end
end
//}
====[a:break] break
//emlist[例][ruby]{
i = 0
while i < 3
print i, "\n"
break
end
//... -
File
:: Stat # <=>(o) -> Integer | nil (22.0) -
ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。
...ファイルの最終更新時刻を比較します。self が other よりも
新しければ正の数を、等しければ 0 を古ければ負の数を返します。
比較できない場合は nil を返します。
@param o File::Stat のインスタンスを指定します。
//emlist[][ru......by]{
require 'tempfile' # for Tempfile
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.n... -
Pathname
# ctime -> Time (22.0) -
File.ctime(self.to_s) を渡したものと同じです。
...File.ctime(self.to_s) を渡したものと同じです。
//emlist[例][ruby]{
require 'pathname'
IO.write("testfile", "test")
pathname = Pathname("testfile")
pathname.ctime # => 2019-01-14 00:39:51 +0900
sleep 1
pathname.chmod(0755)
pathname.ctime # => 2019-01-14 00:39:52 +0900
//}
@see File.ct... -
SignalException
# signm -> String (22.0) -
self.message のエイリアスです。
...
self.message のエイリアスです。
//emlist[例][ruby]{
begin
Process.kill('HUP', Process.pid)
sleep
rescue SignalException => e
puts e.signm # => SIGHUP
end
//}...