クラス
- Mutex (4)
- Thread (16)
-
Thread
:: ConditionVariable (24) -
Thread
:: Mutex (30)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - ConditionVariable (12)
- Monitor (12)
- MonitorMixin (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 3
. 0 . 0 (5) -
SC
_ REALTIME _ SIGNALS (12) -
handle
_ interrupt (12) -
ignore
_ deadlock= (4) - lock (12)
-
pipeline
_ r (24) -
pipeline
_ start (24) -
rb
_ thread _ signal _ raise (12) -
ruby 1
. 8 . 4 feature (12) - synchronize (10)
- unlock (12)
- wait (12)
検索結果
先頭5件
-
Thread
:: Mutex # synchronize { . . . } -> object (3006.0) -
mutex をロックし、ブロックを実行します。実行後に必ず mutex のロックを解放します。
...。
ブロックが最後に評価した値を返します。
@raise ThreadError self 既にカレントスレッドにロックされている場合に発
生します。
また、Signal.#trap に指定したハンドラ内で実行
した... -
NEWS for Ruby 2
. 0 . 0 (156.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...utex#try_lock, Mutex#synchronize, Mutex#sleep
はトラップハンドラの中では使えなくなりました。そのようなときは ThreadError が発生します
* Mutex#sleep may spurious wakeup. Check after wakeup.
* NilClass
* 追加: NilClass#to_h 空のハッシュ......加(起動時にチェックします):
* RUBY_THREAD_VM_STACK_SIZE: vm stack size used at thread creation.
default: 128KB (32bit CPU) or 256KB (64bit CPU).
* RUBY_THREAD_MACHINE_STACK_SIZE: machine stack size used at thread
creation. default: 512KB or 1024KB.
* RUB......う定数を追加しました。RubyVM のデフォルトのパラメータを返します。
* Signal
* 追加: Signal.signame シグナルの名前を返します
* 非互換: Signal.trap は :SEGV, :BUS, :ILL, :FPE, :VTALRM が指定されると ArgumentError を発生させます... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (132.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...]
1
== 追加されたクラス/モジュール
: ((<Process::UID>)) [new]
: ((<Process::GID>)) [new]
: ((<Process::Sys>)) [new]
: ((<Signal>)) モジュール [new]
: ((<Process::Status>)) [new]
: ((<NoMethodError>)) [new]
((<Process::Status>)) の追加により、(......ようになりました。
NoMethodError < NameError < StandardError.
: ((<Interrupt>)) [change]
Interrupt は、((<SignalException>))のサブクラスになりました。
(1.6以前はExceptionのサブクラス)
== 追加されたメソッド
=== 組み込み関......=== Thread
: ((<Thread#keys|Thread/keys>)) [new]
追加。Thread固有データのキーの配列を返します。
: ((<Thread#terminate|Thread/terminate>)) [new]
追加。Thread#kill と同じ。
: ((<Thread#group|Thread/group>)) [new]
追加
=== ThreadGroup
: ((<ThreadGroup#enc... -
Open3
. # pipeline _ r(*cmds) -> [IO , [Thread]] (107.0) -
指定したコマンドのリストをパイプで繋いで順番に実行します。最後の コマンドの標準出力を受けとる事ができます。
...します。
例:
require "open3"
Open3.pipeline_r("yes", "head -10") {|r, ts|
p r.read #=> "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"
p ts[0].value #=> #<Process::Status: pid 24910 SIGPIPE (signal 13)>
p ts[1].value #=> #<Process::Status: pid 24913 exit 0>
}
@see Open3.#popen3... -
Open3
. # pipeline _ start(*cmds) -> [Thread] (107.0) -
指定したコマンドのリストをパイプで繋いで順番に実行します。
...ッ
ドの配列を返します。
例:
require "open3"
# xeyesを10秒だけ実行する。
Open3.pipeline_start("xeyes") {|ts|
sleep 10
t = ts[0]
Process.kill("TERM", t.pid)
p t.value #=> #<Process::Status: pid 911 SIGTERM (signal 15)>
}
@see Open3.#popen3... -
ruby 1
. 8 . 4 feature (48.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...feature/Array#fill [bug]>))
* ((<ruby 1.8.4 feature/String#scan [bug]>))
* ((<ruby 1.8.4 feature/File.join [bug]>))
* ((<ruby 1.8.4 feature/Thread#pass [bug]>))
* ((<ruby 1.8.4 feature/Module#const_missing [bug]>))
* ((<ruby 1.8.4 feature/IO [bug]>))
* ((<ruby 1.8.4 feature/添付ライ......0
: シグナル [bug]
#Sun Oct 16 03:38:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
#
# * rubysig.h (CHECK_INTS): prevent signal handler to run during
# critical section. [ruby-core:04039]
シグナルハンドラの実行はクリティカルセクション......(<ruby-core:06326>))
: Thread#pass [bug]
#Sun Oct 16 03:38:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
#
# * eval.c (load_wait): need not to call rb_thread_schedule()
# explicitly. [ruby-core:04039]
#
# * eval.c (rb_thread_schedule): clear rb_thread_critical.
# [... -
NEWS for Ruby 3
. 0 . 0 (36.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...M1.include M2
p C.ancestors #=> [C, M1, M2, Object, Kernel, BasicObject]
//}
* Mutex
* `Mutex` is now acquired per-`Fiber` instead of per-`Thread`. This change should be compatible for essentially all usages and avoids blocking when using a scheduler. 16792
* Proc
* Proc#== and Proc#eq......ontext is blocking. 16786
* Thread#join invokes the scheduler hooks `block`/`unblock` in a non-blocking execution context. 16786
* Thread
* Thread.ignore_deadlock accessor has been added for disabling the default deadlock detection, allowing the use of signal handlers to break deadlock. 13......JIT-ed code.
* Avoid GC-ing JIT-ed code when not necessary.
* GC-ing JIT-ed code is executed in a background thread.
* Reduce the number of locks between Ruby and JIT threads.
== Static analysis
=== RBS
* RBS is a new language for type definition of Ruby programs. It allows writing... -
Monitor (18.0)
-
スレッドの同期機構としてのモニター機能を提供するクラスです。 また同じスレッドから何度も lock できる Mutex としての機能も提供します。
...mpty_cond = mon.new_cond
# consumer
Thread.start do
loop do
mon.synchronize do
empty_cond.wait_while { buf.empty? }
print buf.shift
end
end
end
# producer
while line = ARGF.gets
mon.synchronize do
buf.push(line)
empty_cond.signal
end
end
//}
2回ロックして......'monitor'
mon = Monitor.new
mon.synchronize {
mon.synchronize {
}
}
//}
Thread::Mutex ではデッドロックになります。
//emlist[Mutex でデッドロックになる例][ruby]{
mx = Mutex.new
mx.synchronize {
mx.synchronize {
}
}
# => deadlock; recursive locking (ThreadError)
//}... -
MonitorMixin (12.0)
-
スレッドの同期機構としてのモニター機能を提供するモジュールです。
...itorMixin) # 配列にモニタ機能を追加
empty_cond = buf.new_cond # 配列が空であるかないかを通知する条件変数
# consumer
Thread.start do
loop do
buf.synchronize do # ロックする
empty_cond.wait_while { buf.empty? } # 配列が空である間はロックを......end
end
# producer
while line = ARGF.gets
buf.synchronize do # ロックする
buf.push(line) # 配列を変更(追加)
empty_cond.signal # 配列に要素が追加されたことを条件変数を通して通知
end # ここでロックを開放
end
//}
=== 初期化
MonitorMixin... -
Mutex
# lock -> self (12.0) -
mutex オブジェクトをロックします。一度に一つのス レッドだけが mutex をロックできます。既にロックされている mutex に対してロックを行おうとしたスレッドは mutex のロックが解放さ れるまで、実行が停止されます。
...す。
@raise ThreadError self 既にカレントスレッドにロックされている場合に発
生します。
また、Signal.#trap に指定したハンドラ内で実行
した場合に発生します。
@see Thread::Mutex#unlock... -
Mutex
# unlock -> self (12.0) -
mutex のロックを解放します。mutex のロック待ちになっていたスレッドの実行は再開されます。
...は出来ません。
ロックしたスレッド以外から unlock が呼ばれると ThreadError が発生します。
m = Mutex.new
m.lock
Thread.new do
m.unlock # => ThreadError
end.join
@raise ThreadError self がロックされていない場合や self をロックしたス......レッド以外から呼ばれた場合に発生します。
また、Signal.#trap に指定したハンドラ内で実行
した場合に発生します。... -
Open3
. # pipeline _ r(*cmds) {|last _ stdout , wait _ thrs| . . . } -> () (7.0) -
指定したコマンドのリストをパイプで繋いで順番に実行します。最後の コマンドの標準出力を受けとる事ができます。
...します。
例:
require "open3"
Open3.pipeline_r("yes", "head -10") {|r, ts|
p r.read #=> "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"
p ts[0].value #=> #<Process::Status: pid 24910 SIGPIPE (signal 13)>
p ts[1].value #=> #<Process::Status: pid 24913 exit 0>
}
@see Open3.#popen3...