module Concurrent::ActorContext

def self.included(base)

def self.included(base)
  class << base
    # Create a single, unregistered actor. The actor will run on its own, dedicated
    # thread. The thread will be started the first time a message is post to the actor.
    # Should the thread ever die it will be restarted the next time a message is post.
    #
    # @param [Hash] opts the options defining actor behavior
    # @option opts [Array] :args (`nil`) arguments to be passed to the actor constructor
    #
    # @return [SimpleActorRef] the `ActorRef` encapsulating the actor
    def spawn(opts = {})
      args = opts.fetch(:args, [])
      Concurrent::SimpleActorRef.new(self.new(*args), opts)
    end
  end
end

def on_error(time, message, exception)

Parameters:
  • exception (Exception) -- the exception object that was raised
  • message (Array) -- the message that caused the error
  • time (Time) -- the date/time at which the error occurred
def on_error(time, message, exception)
end

def on_shutdown

Callback method called by the `ActorRef` which encapsulates the actor instance.
def on_shutdown
end

def on_start

Callback method called by the `ActorRef` which encapsulates the actor instance.
def on_start
end

def spawn(opts = {})

Returns:
  • (SimpleActorRef) - the `ActorRef` encapsulating the actor

Options Hash: (**opts)
  • :args (Array) -- arguments to be passed to the actor constructor

Parameters:
  • opts (Hash) -- the options defining actor behavior
def spawn(opts = {})
  args = opts.fetch(:args, [])
  Concurrent::SimpleActorRef.new(self.new(*args), opts)
end