91件ヒット
[1-91件を表示]
(0.098秒)
ライブラリ
- ビルトイン (40)
- fiber (8)
- irb (12)
-
irb
/ extend-command (12) -
minitest
/ spec (1) - thwait (18)
クラス
- Data (6)
- Fiber (12)
-
MiniTest
:: Spec (1) - Thread (30)
- ThreadsWait (18)
モジュール
- IRB (12)
-
IRB
:: ExtendCommandBundle (12)
キーワード
- CurrentContext (12)
-
all
_ waits (12) - define (6)
-
install
_ extend _ commands (12) - new (6)
-
report
_ on _ exception (9) -
report
_ on _ exception= (9)
検索結果
先頭5件
-
Fiber
. current -> Fiber (24220.0) -
このメソッドが評価されたコンテキストにおける Fiber のインスタンスを返します。
...のメソッドが評価されたコンテキストにおける Fiber のインスタンスを返します。
//emlist[例:][ruby]{
fr = Fiber.new do
Fiber.current
end
fb = fr.resume
p fb.equal?(fr) # => true
p Fiber.current # => #<Fiber:0x91345e4>
p Fiber.current # => #<Fiber:0x91345e4>
//}... -
Thread
. current -> Thread (24208.0) -
現在実行中のスレッド(カレントスレッド)を返します。
...現在実行中のスレッド(カレントスレッド)を返します。
p Thread.current #=> #<Thread:0x4022e6fc run>... -
MiniTest
:: Spec . current -> MiniTest :: Spec (24202.0) -
現在実行中の MiniTest::Spec のインスタンスを返します。
...現在実行中の MiniTest::Spec のインスタンスを返します。... -
IRB
. CurrentContext -> IRB :: Context (12201.0) -
現在の irb に関する IRB::Context を返します。
...現在の irb に関する IRB::Context を返します。... -
IRB
:: ExtendCommandBundle . install _ extend _ commands -> object (9107.0) -
定義済みの拡張を読み込みます。
...。(それぞれ 1 つだけ抜粋)
* irb_current_working_workspace
* irb_change_workspace
* irb_workspaces
* irb_push_workspace
* irb_pop_workspace
* irb_load
* irb_require
* irb_source
* irb
* irb_jobs
* irb_fg
* irb_kill
* irb_help
irb/extend-command が require された時にラ......イブラリ内部で自動的
に実行されます。
@see IRB::ExtendCommandBundle.install_extend_commands... -
Thread
. report _ on _ exception -> bool (6107.0) -
真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...、その内容を $stderr に報告します。
デフォルトは false です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from......-e:1:in `block in <main>'
1: from -e:1:in `times'
これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:......が終了しないようにするのがより良い方法です。
* Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレポートを無効化しても
安全です。......、その内容を $stderr に報告します。
デフォルトは true です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from... -
Thread
. report _ on _ exception=(newstate) (6107.0) -
真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...、その内容を $stderr に報告します。
デフォルトは false です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from......-e:1:in `block in <main>'
1: from -e:1:in `times'
これによってスレッドのエラーを早期に捕捉できるようになります。
いくつかのケースでは、この出力を望まないかもしれません。
出力を抑制するには複数の方法があります:......が終了しないようにするのがより良い方法です。
* Thread#join や Thread#value でそのスレッドの終了を待つことが保証できるなら、
スレッド開始時に Thread.current.report_on_exception = false でレポートを無効化しても
安全です。......、その内容を $stderr に報告します。
デフォルトは true です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from... -
ThreadsWait
. all _ waits(*threads) -> () (6107.0) -
指定されたスレッドすべてが終了するまで待ちます。 ブロックが与えられた場合、スレッド終了時にブロックを評価します。
...m threads 終了するまでまつスレッドを一つもしくは複数指定します。
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
ThreadsWait.all_waits(*threads) {|th| printf("end %s\n", th.inspect) }
# 出力例
#=> #<T......hread:0x21584 run>
#=> #<Thread:0x21610 run>
#=> #<Thread:0x2169c run>
#=> #<Thread:0x21728 run>
#=> #<Thread:0x214f8 run>
#=> end #<Thread:0x21584 dead>
#=> end #<Thread:0x21610 dead>
#=> end #<Thread:0x2169c dead>
#=> end #<Thread:0x21728 dead>
#=> end #<Thread:0x214f8 dead>... -
ThreadsWait
. all _ waits(*threads) {|thread| . . . } -> () (6107.0) -
指定されたスレッドすべてが終了するまで待ちます。 ブロックが与えられた場合、スレッド終了時にブロックを評価します。
...m threads 終了するまでまつスレッドを一つもしくは複数指定します。
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
ThreadsWait.all_waits(*threads) {|th| printf("end %s\n", th.inspect) }
# 出力例
#=> #<T......hread:0x21584 run>
#=> #<Thread:0x21610 run>
#=> #<Thread:0x2169c run>
#=> #<Thread:0x21728 run>
#=> #<Thread:0x214f8 run>
#=> end #<Thread:0x21584 dead>
#=> end #<Thread:0x21610 dead>
#=> end #<Thread:0x2169c dead>
#=> end #<Thread:0x21728 dead>
#=> end #<Thread:0x214f8 dead>... -
ThreadsWait
. new(*threads) -> ThreadsWait (3207.0) -
指定されたスレッドの終了をまつための、スレッド同期オブジェクトをつくります。
...m threads 終了を待つスレッドを一つもしくは複数指定します。
使用例
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { 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>
#=> end #<Thread:0x214bc dead>
#=> end #<Thread:0x21548 dead>
#=> end #<Thread:0x215d4 dead>
#=> end #<Thread:0x21660 dead>
#=> end #<Thread:0x214... -
Data
. define(*args) -> Class (3013.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...Data クラスに新しいサブクラスを作って、それを返します。
サブクラスでは値オブジェクトのメンバに対するアクセスメソッドが定義されています。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # =>......list[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}
メンバを持たないサブクラスも定義可能です。
以下のように、パターンマッチに利用できます。
//emlist[例][ruby]{
class HTTPFetcher
Response = Data.......body)
NotFound = Data.define
def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end
def fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Resp... -
Data
. define(*args) {|subclass| block } -> Class (3013.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...Data クラスに新しいサブクラスを作って、それを返します。
サブクラスでは値オブジェクトのメンバに対するアクセスメソッドが定義されています。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # =>......list[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}
メンバを持たないサブクラスも定義可能です。
以下のように、パターンマッチに利用できます。
//emlist[例][ruby]{
class HTTPFetcher
Response = Data.......body)
NotFound = Data.define
def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end
def fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Resp...