Module: Concurrent::ErlangActor::Functions
- Included in:
- Concurrent::ErlangActor
- Defined in:
- lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb
Overview
A module containing entry functions to actors like spawn_actor, terminate_actor. It can be included in environments working with actors.
Instance Method Summary collapse
-
#default_actor_executor ⇒ ExecutorService
The default executor service for actors.
-
#default_executor ⇒ ExecutorService
The default executor service, may be shared by other abstractions.
-
#spawn_actor(*args, type:, channel: Promises::Channel.new, environment: Environment, name: nil, executor: default_actor_executor, &body) ⇒ Pid
Creates an actor.
-
#terminate_actor(pid, reason) ⇒ true
Same as Environment#terminate, but it requires pid.
Instance Method Details
#default_actor_executor ⇒ ExecutorService
Returns the default executor service for actors.
523 524 525 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 523 def default_actor_executor default_executor end |
#default_executor ⇒ ExecutorService
Returns the default executor service, may be shared by other abstractions.
529 530 531 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 529 def default_executor :io end |
#spawn_actor(*args, type:, channel: Promises::Channel.new, environment: Environment, name: nil, executor: default_actor_executor, &body) ⇒ Pid
Creates an actor. Same as Environment#spawn but lacks link and monitor options.
496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 496 def spawn_actor(*args, type:, channel: Promises::Channel.new, environment: Environment, name: nil, executor: default_actor_executor, &body) actor = ErlangActor.create type, channel, environment, name, executor actor.run(*args, &body) return actor.pid end |
#terminate_actor(pid, reason) ⇒ true
Same as Environment#terminate, but it requires pid.
513 514 515 516 517 518 519 520 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb', line 513 def terminate_actor(pid, reason) if reason == :kill pid.tell Kill.new(nil) else pid.tell Terminate.new(nil, reason, false) end true end |