class Celluloid::Condition::Waiter - celluloid-0.16.0 Documentation

# class Celluloid::Condition::Waiter

### Attributes

condition[R]
task[R]

### Public Class Methods

new(condition, task, mailbox, timeout) click to toggle source

    # File lib/celluloid/condition.rb, line 7
    def initialize(condition, task, mailbox, timeout)
      @condition = condition
      @task = task
      @mailbox = mailbox
      @timeout = timeout
    end

### Public Instance Methods

<<(message) click to toggle source

    # File lib/celluloid/condition.rb, line 15
    def <<(message)
      @mailbox << message
    end

wait() click to toggle source

    # File lib/celluloid/condition.rb, line 19
    def wait
      begin
        message = @mailbox.receive(@timeout) do |msg|
          msg.is_a?(SignalConditionRequest) && msg.task == Thread.current
        end
      rescue TimeoutError
        raise ConditionError, "timeout after #{@timeout.inspect} seconds"
      end until message

      message.value
    end