Class: Moneta::Pool::Reply Private

Inherits:
Object
  • Object
show all
Defined in:
lib/moneta/pool.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mutex) ⇒ Reply

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Reply.



50
51
52
53
54
# File 'lib/moneta/pool.rb', line 50

def initialize(mutex)
  @mutex = mutex
  @resource = ::ConditionVariable.new
  @value = nil
end

Instance Attribute Details

#resourceObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
# File 'lib/moneta/pool.rb', line 48

def resource
  @resource
end

Instance Method Details

#resolve(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



56
57
58
59
60
61
62
63
# File 'lib/moneta/pool.rb', line 56

def resolve(value)
  @mutex.synchronize do
    raise "Already resolved" if @value
    @value = value
    @resource.signal
  end
  nil
end

#waitObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



65
66
67
68
# File 'lib/moneta/pool.rb', line 65

def wait
  @resource.wait(@mutex)
  @value
end