Class: Concurrent::Actor::Behaviour::Abstract

Inherits:
Object
  • Object
show all
Includes:
InternalDelegations, TypeCheck
Defined in:
lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(core, subsequent, core_options) ⇒ Abstract

Returns a new instance of Abstract.



14
15
16
17
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb', line 14

def initialize(core, subsequent, core_options)
  @core       = Type! core, Core
  @subsequent = Type! subsequent, Abstract, NilClass
end

Instance Attribute Details

#coreundocumented (readonly)



12
13
14
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb', line 12

def core
  @core
end

#subsequentundocumented (readonly)



12
13
14
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb', line 12

def subsequent
  @subsequent
end

Instance Method Details

#broadcast(public, event) ⇒ undocumented

broadcasts event to all behaviours and context



39
40
41
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb', line 39

def broadcast(public, event)
  core.broadcast(public, event)
end

#on_envelope(envelope) ⇒ undocumented

Note:

super needs to be called not to break the chain

override to add extra behaviour



21
22
23
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb', line 21

def on_envelope(envelope)
  pass envelope
end

#on_event(public, event) ⇒ undocumented

Note:

super needs to be called not to break the chain

override to add extra behaviour



32
33
34
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb', line 32

def on_event(public, event)
  subsequent.on_event public, event if subsequent
end

#pass(envelope) ⇒ undocumented

Parameters:



26
27
28
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb', line 26

def pass(envelope)
  subsequent.on_envelope envelope
end

#reject_envelope(envelope) ⇒ undocumented



43
44
45
46
47
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb', line 43

def reject_envelope(envelope)
  envelope.reject! ActorTerminated.new(reference)
  dead_letter_routing << envelope unless envelope.future
  log(DEBUG) { "rejected #{envelope.message} from #{envelope.sender_path}"}
end

#behaviour(behaviour_class) ⇒ undocumented Originally defined in module InternalDelegations

see Core#behaviour

#behaviour!(behaviour_class) ⇒ undocumented Originally defined in module InternalDelegations

see Core#behaviour!

#Child!(value, *types) ⇒ undocumented Originally defined in module TypeCheck

#Child?(value, *types) ⇒ Boolean Originally defined in module TypeCheck

Returns:

  • (Boolean)

#childrenundocumented Originally defined in module InternalDelegations

See Also:

#contextAbstractContext Originally defined in module InternalDelegations

Returns:

#context_classundocumented Also known as: actor_class Originally defined in module PublicDelegations

See Also:

#dead_letter_routingundocumented Originally defined in module InternalDelegations

#executorundocumented Originally defined in module PublicDelegations

See Also:

#log(level, message = nil, &block) ⇒ undocumented Originally defined in module InternalDelegations

delegates to core.log

See Also:

  • Logging#log

#Match!(value, *types) ⇒ undocumented Originally defined in module TypeCheck

#Match?(value, *types) ⇒ Boolean Originally defined in module TypeCheck

Returns:

  • (Boolean)

#nameundocumented Originally defined in module PublicDelegations

See Also:

#parentundocumented Originally defined in module PublicDelegations

See Also:

#pathundocumented Originally defined in module PublicDelegations

See Also:

#redirect(reference, envelope = self.envelope) ⇒ undocumented Originally defined in module InternalDelegations

#referenceundocumented Also known as: ref Originally defined in module PublicDelegations

See Also:

#terminate!(reason = nil) ⇒ undocumented Originally defined in module InternalDelegations

See Also:

  • Termination#terminate!

#terminated?Boolean Originally defined in module InternalDelegations

Returns:

  • (Boolean)

See Also:

  • Termination#terminated?

#Type!(value, *types) ⇒ undocumented Originally defined in module TypeCheck

#Type?(value, *types) ⇒ Boolean Originally defined in module TypeCheck

Returns:

  • (Boolean)