Parent

Class/Module Index [+]

Quicksearch

Celluloid::Receivers

Allow methods to directly interact with the actor protocol

Public Class Methods

new() click to toggle source
# File lib/celluloid/receivers.rb, line 7
def initialize
  @receivers = Set.new
  @timers = Timers.new
end

Public Instance Methods

fire_timers() click to toggle source

Fire any pending timers

# File lib/celluloid/receivers.rb, line 37
def fire_timers
  @timers.fire
end
handle_message(message) click to toggle source

Handle incoming messages

# File lib/celluloid/receivers.rb, line 42
def handle_message(message)
  receiver = @receivers.find { |r| r.match(message) }
  return unless receiver

  @receivers.delete receiver
  @timers.cancel receiver.timer if receiver.timer
  receiver.resume message
end
receive(timeout = nil, &block) click to toggle source

Receive an asynchronous message

# File lib/celluloid/receivers.rb, line 13
def receive(timeout = nil, &block)
  if Celluloid.exclusive?
    Celluloid.mailbox.receive(timeout, &block)
  else
    receiver = Receiver.new block

    if timeout
      receiver.timer = @timers.after(timeout) do
        @receivers.delete receiver
        receiver.resume
      end
    end

    @receivers << receiver
    Task.suspend :receiving
  end
end
wait_interval() click to toggle source

How long to wait until the next timer fires

# File lib/celluloid/receivers.rb, line 32
def wait_interval
  @timers.wait_interval
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.