Whole class should be considered private. An user should use Contexts and References only.
Note:devel: core should not block on anything, e.g. it cannot wait on children to terminate that would eat up all threads in task pool and deadlock
Core of the actor.
Instance Attribute Summary collapseA subclass of AbstractContext representing Actor's behaviour.
Executor which is used to process messages.
The name of actor instance, it should be uniq (not enforced).
Path of this actor.
Reference to this actor which can be safely passed around.
Based on behaviour_class.
Based on behaviour_class.
Of children actors.
ensures that we are inside of the executor.
A new instance of Core.
is executed by Reference scheduling processing of new messages can be called from other alternative Reference implementations.
A parent Actor.
Schedules blocks to be executed on executor sequentially, sets Actress.current.
Returns a new instance of Core.
50 51 52 53
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 50 def initialize(opts = {}, &block) super(&nil) synchronize { ns_initialize(opts, &block) } endInstance Attribute Details #actor_class ⇒ Context
35
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 35 attr_reader :reference, :name, :path, :executor, :context_class, :context, :behaviour_definition#behaviour_definition ⇒ undocumented
35 36 37
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 35 def behaviour_definition @behaviour_definition end#context ⇒ undocumented
35 36 37
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 35 def context @context end#context_class ⇒ undocumented
35 36 37
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 35 def context_class @context_class end#executor ⇒ Executor
Executor which is used to process messages.
35
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 35 attr_reader :reference, :name, :path, :executor, :context_class, :context, :behaviour_definition#name ⇒ String
The name of actor instance, it should be uniq (not enforced). Allows easier orientation between actor instances.
35
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 35 attr_reader :reference, :name, :path, :executor, :context_class, :context, :behaviour_definition#path ⇒ String
Path of this actor. It is used for easier orientation and logging. Path is constructed recursively with: parent.path + self.name
up to a Concurrent::Actor.root, e.g. /an_actor/its_child
.
35
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 35 attr_reader :reference, :name, :path, :executor, :context_class, :context, :behaviour_definition#reference ⇒ Reference
Reference to this actor which can be safely passed around.
35 36 37
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 35 def reference @reference endInstance Method Details #add_child(child) ⇒ undocumented
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 77 78 79
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 74 def add_child(child) guard! Type! child, Reference @children.add child nil end#allocate_context ⇒ undocumented
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
150 151 152
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 150 def allocate_context @context = @context_class.allocate end#behaviour(behaviour_class) ⇒ Behaviour::Abstract, nil
Returns based on behaviour_class.
138 139 140
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 138 def behaviour(behaviour_class) @behaviours[behaviour_class] end#behaviour!(behaviour_class) ⇒ Behaviour::Abstract
Returns based on behaviour_class.
145 146 147
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 145 def behaviour!(behaviour_class) @behaviours.fetch behaviour_class end#broadcast(public, event) ⇒ undocumented
131 132 133 134
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 131 def broadcast(public, event) log(DEBUG) { "event: #{event.inspect} (#{public ? 'public' : 'private'})" } @first_behaviour.on_event(public, event) end#build_context ⇒ undocumented
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
155 156 157 158
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 155 def build_context @context.send :initialize_core, self @context.send :initialize, *@args, &@block end#children ⇒ Array<Reference>
Returns of children actors.
68 69 70 71
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 68 def children guard! @children.to_a end#dead_letter_routing ⇒ undocumented
63 64 65
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 63 def dead_letter_routing @context.dead_letter_routing end#guard! ⇒ undocumented
ensures that we are inside of the executor
102 103 104 105 106
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 102 def guard! unless Actor.current == reference raise "can be called only inside actor #{reference} but was #{Actor.current}" end end#log(level, message = nil, &block) ⇒ undocumented
108 109 110
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 108 def log(level, message = nil, &block) super level, @path, message, &block end#on_envelope(envelope) ⇒ undocumented
is executed by Reference scheduling processing of new messages can be called from other alternative Reference implementations
92 93 94 95 96 97 98 99
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 92 def on_envelope(envelope) log(DEBUG) { "is #{envelope.future ? 'asked' : 'told'} #{envelope.message.inspect} by #{envelope.sender}" } schedule_execution do log(DEBUG) { "was #{envelope.future ? 'asked' : 'told'} #{envelope.message.inspect} by #{envelope.sender} - processing" } process_envelope envelope end nil end#parent ⇒ Reference, nil
58 59 60
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 58 def parent @parent_core && @parent_core.reference end#process_envelope(envelope) ⇒ undocumented
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 161 def process_envelope(envelope) @first_behaviour.on_envelope envelope end#remove_child(child) ⇒ undocumented
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
82 83 84 85 86 87
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 82 def remove_child(child) guard! Type! child, Reference @children.delete child nil end#schedule_execution ⇒ undocumented
Schedules blocks to be executed on executor sequentially, sets Actress.current
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
# File 'lib/concurrent-ruby-edge/concurrent/actor/core.rb', line 114 def schedule_execution @serialized_execution.post(@executor) do synchronize do begin Thread.current[:__current_actor__] = reference yield rescue => e log FATAL, e ensure Thread.current[:__current_actor__] = nil end end end nil end#Child!(value, *types) ⇒ undocumented Originally defined in module TypeCheck #Child?(value, *types) ⇒ Boolean Originally defined in module TypeCheck #Match!(value, *types) ⇒ undocumented Originally defined in module TypeCheck #Match?(value, *types) ⇒ Boolean Originally defined in module TypeCheck #Type!(value, *types) ⇒ undocumented Originally defined in module TypeCheck #Type?(value, *types) ⇒ Boolean Originally defined in module TypeCheck
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4