別のキーワード
種類
- インスタンスメソッド (161)
- 特異メソッド (11)
- 文書 (11)
クラス
- Array (32)
- BasicObject (22)
- Socket (11)
- Thread (51)
-
Thread
:: Queue (11) -
Thread
:: SizedQueue (33) - ThreadsWait (12)
キーワード
- [] (11)
-
_ _ send _ _ (22) - deq (11)
- fetch (7)
-
join
_ nowait (6) - pack (16)
- pop (11)
-
ruby 1
. 6 feature (11) - shift (22)
- sum (16)
-
thread
_ variable _ get (11) - unix (11)
検索結果
先頭5件
-
Thread
# join -> self (30338.0) -
スレッド self の実行が終了するまで、カレントスレッドを停止し ます。self が例外により終了していれば、その例外がカレントス レッドに対して発生します。
...ドに対して発生します。
limit を指定して、limit 秒過ぎても自身が終了しない場合、nil を返します。
@param limit タイムアウトする時間を整数か小数で指定します。単位は秒です。
@raise ThreadError join を実行することによって......ッドを join したときにも発生します。
以下は、生成したすべてのスレッドの終了を待つ例です。
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| t.join}... -
Thread
# join(limit) -> self | nil (30338.0) -
スレッド self の実行が終了するまで、カレントスレッドを停止し ます。self が例外により終了していれば、その例外がカレントス レッドに対して発生します。
...ドに対して発生します。
limit を指定して、limit 秒過ぎても自身が終了しない場合、nil を返します。
@param limit タイムアウトする時間を整数か小数で指定します。単位は秒です。
@raise ThreadError join を実行することによって......ッドを join したときにも発生します。
以下は、生成したすべてのスレッドの終了を待つ例です。
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| t.join}... -
ThreadsWait
# join(*threads) -> () (30325.0) -
終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。
...つスレッドに指定されたthreadsを加えます。
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new
p thall.threads #=> []
thall.join(*threads)
p thall.threads
#=> [#<Thread:0x216ec dead>, #<Thre... -
ThreadsWait
# join _ nowait(*threads) -> () (21325.0) -
終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。 しかし、実際には終了をまちません。
...スレッドに指定されたthreadsを加えます。
require 'thwait'
threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}
thall = ThreadsWait.new
p thall.threads #=> []
thall.join_nowait(*threads)
p thall.threads #=> [#<Thread:0x21638 sleep>, #<T... -
Thread
:: SizedQueue # shift(non _ block = false) -> object (6224.0) -
キューからひとつ値を取り出します。 キューに push しようと待っているスレッドがあれば、実行を再開させます。
...emlist[例][ruby]{
require 'thread'
q = SizedQueue.new(4)
th1 = Thread.start do
while resource = q.pop
puts resource
end
end
[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}
th1.join
# => resource1
# resource2
# resource3
//}
//emlist[例: nonblock = true][ruby]{
require......'thread'
q = SizedQueue.new(4)
th1 = Thread.start do
while resource = q.pop
puts resource
end
end
[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}
begin
th1.join
q.pop(true)
rescue => e
p e
p e.message
end
# => resource1
# resource2
# resource3
# => #<ThreadErro... -
Thread
# thread _ variable _ get(key) -> object | nil (6218.0) -
引数 key で指定した名前のスレッドローカル変数を返します。
...変数(Fiber ローカル変数)と
異なり、Fiber を切り替えても同じ変数を返す事に注意してください。
例:
Thread.new {
Thread.current.thread_variable_set("foo", "bar") # スレッドローカル
Thread.current["foo"] = "bar" # Fiber ロー......ル
Fiber.new {
Fiber.yield [
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... -
Socket
. unix(path) {|sock| . . . } -> object (6212.0) -
Unix クライアントソケットを生成します。
...Unix クライアントソケットを生成します。
ブロックが省略されたときは、生成されたソケットが返されます。
ブロックが渡されたときは、生成されたソケットを
引数としてブロックを呼び出します。メソッドの返り値は......た、ブロックの終了後に
ソケットを IO#close します。
require 'socket'
# /tmp/sock と通信する
Socket.unix("/tmp/sock") {|sock|
t = Thread.new { IO.copy_stream(sock, STDOUT) }
IO.copy_stream(STDIN, sock)
t.join
}
@param path 接続対象のパス(文字... -
BasicObject
# _ _ send _ _ (name , *args) -> object (6118.0) -
オブジェクトのメソッド name を args を引数にして呼び出し、メソッドの結果を返します。
...//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name, *args)
"(Mail#send) - #{name} #{args.join(',')}"
end
end
mail = Mail.new
mail.send :delete, "gentle", "readers" # => "(Mail#send) - delete gentle,readers"
mail.__se......nd__ :delete, "gentle", "readers" # => "(Mail#delete) - delete gentle,readers"
//}
@see Object#send... -
BasicObject
# _ _ send _ _ (name , *args) { . . . . } -> object (6118.0) -
オブジェクトのメソッド name を args を引数にして呼び出し、メソッドの結果を返します。
...//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name, *args)
"(Mail#send) - #{name} #{args.join(',')}"
end
end
mail = Mail.new
mail.send :delete, "gentle", "readers" # => "(Mail#send) - delete gentle,readers"
mail.__se......nd__ :delete, "gentle", "readers" # => "(Mail#delete) - delete gentle,readers"
//}
@see Object#send... -
ruby 1
. 6 feature (4350.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...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) ->......core:00019>))
: 2002-09-11: Queue#((<Queue/pop>))
Queue#pop に競合状態の問題がありました ((<ruby-dev:17223>))
: 2002-09-11: SizedQueue.new
引数に 0 以下を受けつけるバグが修正されました。
: 2002-09-05: ((<リテラル/式展開>))
stable snapshot で、......08-06) [i586-linux]
-:4:in `name=': can't modify frozen Struct (TypeError)
from -:4
cat = Struct.new("Cat", :name, :age, :life)
a = cat.new("cat", 12, 7)
Thread.new do
abort_on_exception = true
$SAFE = 4
a.life -= 1
end.join
p a.life
=...