Class: Celluloid::Condition::Waiter
- Inherits:
-
Object
- Object
- Celluloid::Condition::Waiter
- Defined in:
- lib/celluloid/condition.rb
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #<<(message) ⇒ Object
-
#initialize(condition, task, mailbox, timeout) ⇒ Waiter
constructor
A new instance of Waiter.
- #wait ⇒ Object
Constructor Details
#initialize(condition, task, mailbox, timeout) ⇒ Waiter
Returns a new instance of Waiter.
5 6 7 8 9 10 |
# File 'lib/celluloid/condition.rb', line 5 def initialize(condition, task, mailbox, timeout) @condition = condition @task = task @mailbox = mailbox @timeout = timeout end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
11 12 13 |
# File 'lib/celluloid/condition.rb', line 11 def condition @condition end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
11 12 13 |
# File 'lib/celluloid/condition.rb', line 11 def task @task end |
Instance Method Details
#<<(message) ⇒ Object
13 14 15 |
# File 'lib/celluloid/condition.rb', line 13 def <<() @mailbox << end |
#wait ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/celluloid/condition.rb', line 17 def wait begin = @mailbox.receive(@timeout) do |msg| msg.is_a?(SignalConditionRequest) && msg.task == Thread.current end rescue TimedOut raise ConditionError, "timeout after #{@timeout.inspect} seconds" end until .value end |