るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. rsa p
  5. matrix p

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

Fiber.current -> Fiber (18139.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 (18115.0)

現在実行中のスレッド(カレントスレッド)を返します。

...現在実行中のスレッド(カレントスレッド)を返します。

p
Thread.current #=> #<Thread:0x4022e6fc run>...

Thread#group -> ThreadGroup (6214.0)

スレッドが属している ThreadGroup オブジェクトを返します。

...スレッドが属している ThreadGroup オブジェクトを返します。

p
Thread.current.group == ThreadGroup::Default
# => true...

Thread#inspect -> String (6108.0)

自身を人間が読める形式に変換した文字列を返します。

...自身を人間が読める形式に変換した文字列を返します。

//emlist[例][ruby]{
a = Thread.current
a.inspect # => "#<Thread:0x00007fdbaf07ddb0 run>"
b = Thread.new{}
b.inspect # => "#<Thread:0x00007fdbaf8f7d10@(irb):3 dead>"
//}...

Thread#priority -> Integer (6108.0)

スレッドの優先度を返します。この値が大きいほど優先度が高くなります。 メインスレッドのデフォルト値は 0 です。新しく生成されたスレッドは親スレッドの priority を引き継ぎます。

...スレッドの
p
riority を引き継ぎます。

@param val スレッドの優先度を指定します。プラットフォームに依存します。

//emlist[例][ruby]{
Thread.current.priority # => 0

count1 = count2 = 0
a = Thread.new do
loop { count1 += 1 }
end
a.priority = -1

b...
...= Thread.new do
loop { count2 += 1 }
end
b.priority = -2
count1 = count2 = 0 # reset
sleep 1 # => 1
count1 # => 13809431
count2 # => 11571921
//}...

絞り込み条件を変える

Thread#priority=(val) (6108.0)

スレッドの優先度を返します。この値が大きいほど優先度が高くなります。 メインスレッドのデフォルト値は 0 です。新しく生成されたスレッドは親スレッドの priority を引き継ぎます。

...スレッドの
p
riority を引き継ぎます。

@param val スレッドの優先度を指定します。プラットフォームに依存します。

//emlist[例][ruby]{
Thread.current.priority # => 0

count1 = count2 = 0
a = Thread.new do
loop { count1 += 1 }
end
a.priority = -1

b...
...= Thread.new do
loop { count2 += 1 }
end
b.priority = -2
count1 = count2 = 0 # reset
sleep 1 # => 1
count1 # => 13809431
count2 # => 11571921
//}...

Thread#stop? -> bool (6108.0)

スレッドが終了(dead)あるいは停止(stop)している時、true を返します。

...スレッドが終了(dead)あるいは停止(stop)している時、true を返します。

//emlist[例][ruby]{
a = Thread.new { Thread.stop }
b = Thread.current
a.stop? # => true
b.stop? # => false
//}

@see Thread#alive?, Thread#status...

Thread.report_on_exception -> bool (6108.0)

真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...alse です。

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 でレポートを無効化しても
安全です。しかし、この場合、例外をハンドルするのが遅れた...
...を待つことができなかったりするかもしれません。

スレッドごとに設定する方法は Thread#report_on_exception= を参照してください。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false...
...true です。

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.report_on_exception=(newstate) (6108.0)

真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...alse です。

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 でレポートを無効化しても
安全です。しかし、この場合、例外をハンドルするのが遅れた...
...を待つことができなかったりするかもしれません。

スレッドごとに設定する方法は Thread#report_on_exception= を参照してください。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false...
...true です。

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'

これ...

ThreadGroup (6020.0)

スレッドグループを表すクラスです。グループに属する Thread をまとめて 操作することができます。

...は ThreadGroup::Default に属します。

: 例:

生成したすべてのThreadが終了するのを待つ

5.times {
Thread.new { sleep 1; puts "#{Thread.current} finished" }
}

(ThreadGroup::Default.list - [Thread.current]).each {|th| th.join}

p
uts "all threads...
...(Thread.exclusive参照)

Thread.exclusive do
(ThreadGroup::Default.list - [Thread.current]).each {|th| th.join}
end

=== ThreadGroup#freeze と ThreadGroup#enclose の違い

どちらのメソッドでも ThreadGroup#add によるスレッドの追加ができなくなる点は同...
...する ThreadGroup が freeze
されている場合、Thread.new{ ... } はエラーになります。ThreadGroup が enclose されているだけでは、
Thread.new{ ... } はエラーになりません。生成されたスレッドは従来通り 親スレッドの ThreadGroup に属します...

絞り込み条件を変える

Process.exec(command, *args) -> () (3008.0)

カレントプロセスを与えられた外部コマンドで置き換えます。

...元の
プログラムからいくつかの環境を引き継ぎます。

@param command 実行する外部コマンド。

@param args command に渡す引数。

exec "echo *" # echoes list of files in current directory
# never get here


exec "echo", "*" # echoes an asterisk...
<< 1 2 > >>