Class: Concurrent::ErlangActor::OnThread
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
Concurrent::ErlangActor::AbstractActor
|
Defined in: | lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb |
Constant Summary
-
TERMINATE =
private
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 1197Module.new
EnvironmentConstants
- Included
Concern::Logging
- Included
Class Attribute Summary
Synchronization::Object
- Inherited
Class Method Summary
AbstractActor
- Inherited
Synchronization::Object
- Inherited
.atomic_attribute?, .atomic_attributes, | |
.attr_atomic | Creates methods for reading and writing to a instance variable with volatile (Java) semantic as |
.attr_volatile | Creates methods for reading and writing (as |
.ensure_safe_initialization_when_final_fields_are_present | For testing purposes, quite slow. |
.new | Has to be called by children. |
.safe_initialization!, .define_initialize_atomic_fields |
Synchronization::AbstractObject
- Inherited
Instance Attribute Summary
AbstractActor
- Inherited
Instance Method Summary
- #receive(*rules, timeout: nil, timeout_value: nil, &given_block)
- #run(*args, &body)
- #terminate_self(reason, value) private
AbstractActor
- Inherited
Concern::Logging
- Included
#log | Logs through Concurrent.global_logger, it can be overridden by setting @logger. |
Synchronization::Object
- Inherited
Synchronization::Volatile
- Included
Synchronization::AbstractObject
- Inherited
Constructor Details
.new(channel, environment, name, executor) ⇒ OnThread
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 1192
def initialize(channel, environment, name, executor) super channel, environment, name, executor @Thread = nil end
Instance Method Details
#receive(*rules, timeout: nil, timeout_value: nil, &given_block)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 1223
def receive(*rules, timeout: nil, timeout_value: nil, &given_block) clean_reply err = canonical_rules rules, timeout, timeout_value, given_block raise err if err rules_matcher = Or[*rules.map(&:first)] matcher = -> m { m.is_a?(Ask) ? rules_matcher === m. : rules_matcher === m } while true = @Mailbox.pop_matching(matcher, timeout, TIMEOUT) log DEBUG, pid, got: unless ( = consume_signal( )) == NOTHING rules.each do |rule, job| return eval_task(, job) if rule === end end end end
#run(*args, &body)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 1200
def run(*args, &body) initial_signal_consumption @Thread = Thread.new(@Terminated, self) do |terminated, _actor| # sync point Thread.abort_on_exception = true final_reason = begin reason, value = catch(TERMINATE) do [:normal, @Environment.instance_exec(*args, &body)] end reason terminated.resolve(reason == :normal, value, reason) reason rescue => e e terminated.reject e e end after_termination final_reason @Thread = nil end end
#terminate_self(reason, value) (private)
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 1244
def terminate_self(reason, value) throw TERMINATE, [reason, value] end