module Concurrent::Actor::Behaviour

Actors have modular architecture, which is achieved by combining a light core with chain of behaviours. Each message or internal event propagates through the chain allowing the behaviours react based on their responsibility.

If needed new behaviours can be added, or old one removed to get required behaviour.

Constants

MESSAGE_PROCESSED

Public Class Methods

base(on_error) click to toggle source

@see '' its source code

# File lib/concurrent/actor/behaviour.rb, line 105
def self.base(on_error)
  [[SetResults, on_error],
   # has to be before Termination to be able to remove children from terminated actor
   RemovesChild,
   Termination]
end
basic_behaviour_definition() click to toggle source

Array of behaviours and their construction parameters.

[[Behaviour::SetResults, :terminate!],
 [Behaviour::RemovesChild],
 [Behaviour::Termination],
 [Behaviour::Linking],
 [Behaviour::Awaits],
 [Behaviour::ExecutesContext],
 [Behaviour::ErrorsOnUnknownMessage]]

@see '' its source code

# File lib/concurrent/actor/behaviour.rb, line 77
def self.basic_behaviour_definition
  [*base(:terminate!),
   *linking,
   *user_messages]
end
linking() click to toggle source

@see '' its source code

# File lib/concurrent/actor/behaviour.rb, line 113
def self.linking
  [Linking]
end
restarting_behaviour_definition(handle = :reset!, strategy = :one_for_one) click to toggle source

Array of behaviours and their construction parameters.

[[Behaviour::SetResults, :pause!],
 [Behaviour::RemovesChild],
 [Behaviour::Termination],
 [Behaviour::Linking],
 [Behaviour::Pausing],
 [Behaviour::Supervising, :reset!, :one_for_one],
 [Behaviour::Awaits],
 [Behaviour::ExecutesContext],
 [Behaviour::ErrorsOnUnknownMessage]]

@see '' its source code

# File lib/concurrent/actor/behaviour.rb, line 96
def self.restarting_behaviour_definition(handle = :reset!, strategy = :one_for_one)
  [*base(:pause!),
   *linking,
   *supervised,
   *supervising(handle, strategy),
   *user_messages]
end
supervised() click to toggle source

@see '' its source code

# File lib/concurrent/actor/behaviour.rb, line 118
def self.supervised
  [Pausing]
end
supervising(handle = :reset!, strategy = :one_for_one) click to toggle source

@see '' its source code

# File lib/concurrent/actor/behaviour.rb, line 123
def self.supervising(handle = :reset!, strategy = :one_for_one)
  [[Behaviour::Supervising, handle, strategy]]
end
user_messages() click to toggle source

@see '' its source code

# File lib/concurrent/actor/behaviour.rb, line 128
def self.user_messages
  [Awaits,
   ExecutesContext,
   ErrorsOnUnknownMessage]
end