るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

クラス

キーワード

検索結果

Thread::SizedQueue#max -> Integer (18115.0)

キューの最大サイズを返します。

...キューの最大サイズを返します。

//emlist[例][ruby]{
q = SizedQueue.new(4)
q.max # => 4
//}...

Thread::SizedQueue#max=(n) (6127.0)

キューの最大サイズを設定します。

...キューの最大サイズを設定します。

@param n キューの最大サイズを指定します。

//emlist[例][ruby]{
require 'thread'
q = SizedQueue.new(4)
q.max # => 4
q.max = 5
q.max # => 5
//}...

Thread::ConditionVariable (50.0)

スレッドの同期機構の一つである状態変数を実現するクラスです。

...変数を実現するクラスです。

以下も ConditionVariable を理解するのに参考になります。

https://ruby-doc.com/docs/ProgrammingRuby/html/tut_threads.html#UF

=== Condition Variable とは

あるスレッド A が排他領域で動いていたとします。スレッド A...
...tex = Mutex.new
cv = ConditionVariable.new

a = Thread.start {
mutex.synchronize {
...
while (条件が満たされない)
cv.wait(mutex)
end
...
}
}

b = Thread.start {
mutex.synchronize {
# 上の...
...
あるいは満タンになった場合に Condition Variable を使って wait しています。

require 'thread'

class TinyQueue
def initialize(max=2)
@max = max
@full = ConditionVariable.new
@empty = ConditionVariable.new
@mutex = Mutex.new
@q = []...