るりまサーチ

最速Rubyリファレンスマニュアル検索!
366件ヒット [1-100件を表示] (0.119秒)
トップページ > クエリ:t[x] > クエリ:@[x] > クラス:Thread[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

検索結果

<< 1 2 3 ... > >>

Thread#terminate -> self (9208.0)

スレッドの実行を終了させます。終了時に ensure 節が実行されます。

...

ただし、スレッドは終了処理中(aborting)にはなりますが、
直ちに終了するとは限りません。すでに終了している場合は何もしません。このメソッドにより
終了したスレッドの Thread#value の返り値は不定です。
自身がメイ...
...exit(0)
により終了します。

Kernel.#exit と違い例外 SystemExit を発生しません。

t
h1 = Thread.new do
begin
sleep 10
ensure
p "this will be displayed"
end
end

sleep 0.1
t
h1.kill

#=> "this will be displayed"

@
see Kernel.#exit, Kernel.#exit!...

Thread#thread_variable?(key) -> bool (9114.0)

引数 key で指定した名前のスレッドローカル変数が存在する場合に true、そ うでない場合に false を返します。

... true、そ
うでない場合に false を返します。

@
param key 変数名を String か Symbol で指定します。

me = Thread.current
me.thread_variable_set(:oliver, "a")
me.thread_variable?(:oliver) # => true
me.thread_variable?(:stanley) # => false

[注意]: Thread#[]...
...でセットしたローカル変数(Fiber ローカル変数)が
対象ではない事に注意してください。

@
see Thread#thread_variable_get, Thread#[]...

Thread#thread_variable_get(key) -> object | nil (9114.0)

引数 key で指定した名前のスレッドローカル変数を返します。

...]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)と
異なり、Fiber を切り替えても同じ変数を返す事に注意してください。

例:

Thread
.new {
Thread
.current.thread_variable_set("foo", "bar") # スレッドローカル
Thread
.current["foo"...
...
Thread
.current.thread_variable_get("foo"), # スレッドローカル
Thread
.current["foo"], # Fiber ローカル
]
}.resume
}.join.value # => ['bar', nil]

この例の "bar" は Thread#thread_variable_get により得られ
た値で、nil はThread...
...#[] により得られた値です。

@
see Thread#thread_variable_set, Thread#[]

@
see https://magazine.rubyist.net/articles/0041/0041-200Special-note.html...

Thread#thread_variable_set(key, value) (9108.0)

引数 key で指定した名前のスレッドローカル変数に引数 value をセットしま す。

...]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)と
異なり、セットした変数は Fiber を切り替えても共通で使える事に注意してく
ださい。

//emlist[例][ruby]{
t
hr = Thread.new do
Thread
.current.thread_variable_set(:cat, 'meow')
Thread
.c...
...urrent.thread_variable_set("dog", 'woof')
end
t
hr.join # => #<Thread:0x401b3f10 dead>
t
hr.thread_variables # => [:dog, :cat]
//}

@
see Thread#thread_variable_get, Thread#[]...

Thread#backtrace_locations(range) -> [Thread::Backtrace::Location] | nil (6226.0)

スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。

...トレースを Thread::Backtrace::Location の配
列で返します。

引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。

@
param start 開始フレームの位置を数値で指定します。

@
param length 取得するフ...
...

@
param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。

Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。

//emlist[例][ruby]{
thread
= Thread.new { sleep 1 }
thread
.run
thread
.backtr...
...ace_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}

@
see Thread::Backtrace::Location...

絞り込み条件を変える

Thread#backtrace_locations(start = 0, length = nil) -> [Thread::Backtrace::Location] | nil (6226.0)

スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。

...トレースを Thread::Backtrace::Location の配
列で返します。

引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。

@
param start 開始フレームの位置を数値で指定します。

@
param length 取得するフ...
...

@
param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。

Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。

//emlist[例][ruby]{
thread
= Thread.new { sleep 1 }
thread
.run
thread
.backtr...
...ace_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}

@
see Thread::Backtrace::Location...

Thread#fetch(name, default = nil) {|name| ... } -> object (6126.0)

name に関連づけられたスレッドに固有のデータを返します。 name に対応するスレッド固有データがない時には、引数 default が 与えられていればその値を、ブロックが与えられていれば そのブロックを評価した値を返します。

...時には、引数 default
与えられていればその値を、ブロックが与えられていれば
そのブロックを評価した値を返します。

@
param name スレッド固有データのキーを文字列か Symbol で指定します。
@
param default name に対応するスレ...
...す。
@
raise KeyError 引数defaultもブロックも与えられてない時、
name に対応するスレッド固有データがないと発生します。

//emlist[例][ruby]{
t
h = Thread.new { Thread.current[:name] = 'A' }
t
h.join
t
h.fetch(:name) # => "A"
t
h.fetch(:fetch, 'B...
...') # => "B"
t
h.fetch('name') {|name| "Thread" + name} # => "A"
t
h.fetch('fetch') {|name| "Thread" + name} # => "Threadfetch"
//}

@
see Thread#[]...

Thread#add_trace_func(pr) -> Proc (6114.0)

スレッドにトレース用ハンドラを追加します。

...

@
param pr トレースハンドラ(Proc オブジェクト)

//emlist[例][ruby]{
t
h = Thread.new do
class Trace
end
43.to_s
end
t
h.add_trace_func lambda {|*arg| p arg }
t
h.join

# => ["line", "example.rb", 4, nil, #<Binding:0x00007f98e107d0d8>, nil]
# => ["c-call", "example.rb", 4, :inherit...
...ed, #<Binding:0x00007f98e1087448>, Class]
# => ["c-return", "example.rb", 4, :inherited, #<Binding:0x00007f98e1085d00>, Class]
# => ["class", "example.rb", 4, nil, #<Binding:0x00007f98e108f210>, nil]
# => ["end", "example.rb", 5, nil, #<Binding:0x00007f98e108e5e0>, nil]
# => ["line", "example.rb", 6...
..., nil, #<Binding:0x00007f98e108d4b0>, nil]
# => ["c-call", "example.rb", 6, :to_s, #<Binding:0x00007f98e1097aa0>, Integer]
# => ["c-return", "example.rb", 6, :to_s, #<Binding:0x00007f98e1095cc8>, Integer]
//}

@
see Thread#set_trace_func Kernel.#set_trace_func...

Thread#pending_interrupt?(error = nil) -> bool (6114.0)

self の非同期例外のキューが空かどうかを返します。

...self の非同期例外のキューが空かどうかを返します。

@
param error 対象の例外クラスを指定します。


@
see Thread.pending_interrupt?...
<< 1 2 3 ... > >>