るりまサーチ

最速Rubyリファレンスマニュアル検索!
116件ヒット [1-100件を表示] (0.049秒)
トップページ > クエリ:new[x] > クエリ:Monitor[x]

別のキーワード

  1. openssl new
  2. _builtin new
  3. rexml/document new
  4. resolv new
  5. socket new

ライブラリ

クラス

モジュール

検索結果

<< 1 2 > >>

Monitor.new -> Monitor (39218.0)

新しい Monitor オブジェクトを生成します。

...新しい Monitor オブジェクトを生成します。...

Monitor (38048.0)

スレッドの同期機構としてのモニター機能を提供するクラスです。 また同じスレッドから何度も lock できる Mutex としての機能も提供します。

...tex としての機能も提供します。

Monitor
Mixin を include し、いくつかの別名を定義したクラスです。

=== 例

//emlist[消費者、生産者問題の例][ruby]{
require 'monitor'

buf = []
mon = Monitor.new
empty_cond = mon.new_cond

# consumer
Thread.start do
loop d...
...ドロックにならない例][ruby]{
require 'monitor'
mon = Monitor.new
mon.synchronize {
mon.synchronize {
}
}
//}

Thread::Mutex ではデッドロックになります。

//emlist[Mutex でデッドロックになる例][ruby]{
mx = Mutex.new
mx.synchronize {
mx.synchronize {
}
}
# =>...

Monitor#new_cond -> MonitorMixin::ConditionVariable (27201.0)

モニターに関連付けられた、新しい MonitorMixin::ConditionVariable を生成して返します。

...モニターに関連付けられた、新しい MonitorMixin::ConditionVariable を生成して返します。...

NEWS for Ruby 2.7.0 (26066.0)

NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 2.7.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...name: "Alice", children: [{name: "Charlie", age: age}]}
#=> NoMatchingPatternError
//}

* 詳細は https://speakerdeck.com/k_tsj/pattern-matching-new-feature-in-ruby-2-dot-7 のスライドを参照してください。
* スライドは少し古い内容になっていることに注意して...
...ext
* singleton
* 以下のdefault gemはruby-coreでの変更のみで、まだrubygems.orgでは公開されていません。
* monitor
* observer
* timeout
* tracer
* uri
* yaml
* did_you_mean gemはbundled gemからdefault gemになりました。...

NEWS for Ruby 3.1.0 (26048.0)

NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 3.1.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...* Thread::Queue
* 変更されたメソッド
* Thread::Queue.new が、初期値のEnumerableオブジェクトを渡せるようになりました。 17327

* Time
* 変更されたメソッド
* Time.new は、Time.at や Time.now と同じようにタイムゾーンの in:...
...のio_wait、io_read、io_writeは、可能ならばオリジナルのIOオブジェクトを受け取るようになりました。 18003
* MonitorがFiberセーフになりました。 17827
* コピーコルーチンをpthread実装に置き換えました。 18015

* Refinement...

絞り込み条件を変える

Monitor#enter -> () (21030.0)

MonitorMixin#mon_enter の別名です。

...MonitorMixin#mon_enter の別名です。

Thread::Mutex#lock に相当します。
Thread::Mutex#lock と違うのは現在のモニターの所有者が現在実行されているスレッドである場合、
何度でもロックできる点です。ロックした回数だけ Monitor#exit を...
...解放されません。

//emlist[例][ruby]{
require 'monitor'
mon = Monitor.new
mon.enter
mon.enter
//}

Thread::Mutex#lock ではデッドロックが起きます。

//emlist[Mutex でデッドロックする例][ruby]{
m = Mutex.new
m.lock
m.lock # => deadlock; recursive locking (ThreadError)...
...だけ Monitor#exit を呼ばなければモニターは
解放されません。

//emlist[例][ruby]{
require 'monitor'
mon = Monitor.new
mon.enter
mon.enter
//}

Thread::Mutex#lock ではデッドロックが起きます。

//emlist[Mutex でデッドロックする例][ruby]{
m = Mutex.new
m.lo...

Monitor#mon_enter -> () (21030.0)

モニターをロックします。

...だけ Monitor#exit を呼ばなければモニターは
解放されません。

//emlist[例][ruby]{
require 'monitor'
mon = Monitor.new
mon.enter
mon.enter
//}

Thread::Mutex#lock ではデッドロックが起きます。

//emlist[Mutex でデッドロックする例][ruby]{
m = Mutex.new
m.lo...

Monitor#wait_for_cond(cond, timeout) -> bool (21024.0)

MonitorMixin::ConditionVariable 用の内部メソッドです。

...MonitorMixin::ConditionVariable 用の内部メソッドです。

@param cond Thread::ConditionVariable を指定します。
@param timeout タイムアウトまでの秒数。指定しなかった場合はタイムアウトしません。

@return タイムアウトしたときは false を返し...
...ます。それ以外は true を返します。

//emlist[例][ruby]{
require 'monitor'
m = Monitor.new
cv = Thread::ConditionVariable.new
m.enter
m.wait_for_cond(cv, 1)
//}...

Monitor#wait_for_cond(cond, timeout) -> true (21024.0)

MonitorMixin::ConditionVariable 用の内部メソッドです。

...MonitorMixin::ConditionVariable 用の内部メソッドです。

@param cond Thread::ConditionVariable を指定します。
@param timeout タイムアウトまでの秒数。指定しなかった場合はタイムアウトしません。

@return Ruby 1.9 の頃からのバグで常に true を...
...返します。(16608)

//emlist[例][ruby]{
require 'monitor'
m = Monitor.new
cv = Thread::ConditionVariable.new
m.enter
m.wait_for_cond(cv, 1)
//}...

Monitor#exit -> () (21018.0)

モニターのロックを解放します。

...MonitorMixin#mon_exit の別名です。

enter でロックした回数だけ exit を呼ばなければモニターは解放されません。

モニターが解放されればモニターのロック待ちになっていた
スレッドが一つ実行を再開します。

@raise ThreadError ロ...
...ックを持っていないスレッドが呼びだした場合に発生します

//emlist[例][ruby]{
require 'monitor'
mon = Monitor.new
mon.enter
mon.enter
mon.exit
mon.exit
mon.exit # => current thread not owner (ThreadError)
//}...
...ドが一つ実行を再開します。

@raise ThreadError ロックを持っていないスレッドが呼びだした場合に発生します

//emlist[例][ruby]{
require 'monitor'
mon = Monitor.new
mon.enter
mon.enter
mon.exit
mon.exit
mon.exit # => current thread not owner (ThreadError)
//}...

絞り込み条件を変える

Monitor#mon_exit -> () (21018.0)

モニターのロックを解放します。

...ドが一つ実行を再開します。

@raise ThreadError ロックを持っていないスレッドが呼びだした場合に発生します

//emlist[例][ruby]{
require 'monitor'
mon = Monitor.new
mon.enter
mon.enter
mon.exit
mon.exit
mon.exit # => current thread not owner (ThreadError)
//}...

MonitorMixin#new_cond -> MonitorMixin::ConditionVariable (9201.0)

モニターに関連付けられた、新しい MonitorMixin::ConditionVariable を生成して返します。

...モニターに関連付けられた、新しい MonitorMixin::ConditionVariable を生成して返します。...

MonitorMixin (6024.0)

スレッドの同期機構としてのモニター機能を提供するモジュールです。

...機能を追加します。

=== 例

//emlist[消費者、生産者問題の例][ruby]{
require 'monitor'

buf = []
buf.extend(MonitorMixin) # 配列にモニタ機能を追加
empty_cond = buf.new_cond # 配列が空であるかないかを通知する条件変数

# consumer
Thread.start do
loo...
...= 初期化

Monitor
Mixin は初期化される必要があります。
上の例のように Object#extend を使って利用する場合は
自動的に初期化されます。

//emlist[extend する例][ruby]{
require 'monitor'
buf = []
buf.extend(MonitorMixin)
//}

しかし、MonitorMixin を...
...け付けないので
super ではなく super() を呼ぶ必要があります。

//emlist[include する例][ruby]{
require 'monitor'

class MyObject
include MonitorMixin

def initialize(val)
super()
@value = val
end

def to_s
synchronize {
@value.to_s
}
end
end
//...

MonitorMixin::ConditionVariable (3048.0)

MonitorMixin と Monitor のための 条件変数クラスです。 MonitorMixin#new_cond が返します。ユーザが MonitorMixin::ConditionVariable.new を直接呼ぶことはありません。

...MonitorMixin と Monitor のための
条件変数クラスです。
Monitor
Mixin#new_cond が返します。ユーザが
Monitor
Mixin::ConditionVariable.new を直接呼ぶことはありません。...
<< 1 2 > >>