class Actor::Start

Attributes

actor[R]
supervisor_address[RW]

Public Class Methods

call(actor_or_actor_class, *arguments, &block) click to toggle source
# File lib/actor/start.rb, line 12
def self.call actor_or_actor_class, *arguments, &block
  if actor_or_actor_class.is_a? Actor and not actor_or_actor_class.is_a? Class
    actor = actor_or_actor_class
  else
    actor = Build.(actor_or_actor_class, *arguments, &block)
  end

  instance = new actor
  instance.send = Messaging::Send.new
  instance.supervisor_address = Supervisor::Address::Get.()
  instance.()
end
new(actor) click to toggle source
# File lib/actor/start.rb, line 8
def initialize actor
  @actor = actor
end

Public Instance Methods

actor_crashed(error) click to toggle source
# File lib/actor/start.rb, line 42
def actor_crashed error
  actor_crashed = Messages::ActorCrashed.new error, actor
  send.(actor_crashed, supervisor_address)
end
actor_started() click to toggle source
# File lib/actor/start.rb, line 47
def actor_started
  actor_started = Messages::ActorStarted.new address, actor
  send.(actor_started, supervisor_address)
end
actor_stopped() click to toggle source
# File lib/actor/start.rb, line 52
def actor_stopped
  actor_stopped = Messages::ActorStopped.new address, actor
  send.(actor_stopped, supervisor_address)
end
address() click to toggle source
# File lib/actor/start.rb, line 57
def address
  actor.address
end
call() click to toggle source
# File lib/actor/start.rb, line 25
def call
  send.(Messages::Start, address)

  thread = Thread.new do
    actor_started

    begin
      actor.run_loop
      actor_stopped
    rescue => error
      actor_crashed error
    end
  end

  return actor, thread
end