module Concurrent::ErlangActor::Functions

A module containing entry functions to actors like #spawn_actor, terminate_actor. It can be included in environments working with actors. @example

include Concurrent::ErlangActors::Functions
actor = spawn_actor :on_pool do
  receive { |data| process data }
end

@see FunctionShortcuts

Public Instance Methods

default_actor_executor() click to toggle source

@return [ExecutorService] the default executor service for actors

# File lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb, line 519
def default_actor_executor
  default_executor
end
default_executor() click to toggle source

@return [ExecutorService] the default executor service,

may be shared by other abstractions
# File lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb, line 525
def default_executor
  :io
end
spawn_actor(*args, type:, channel: Promises::Channel.new, environment: Environment, name: nil, executor: default_actor_executor, &body) click to toggle source

Creates an actor. Same as {Environment#spawn} but lacks link and monitor options. @param [Object] args @param [:on_thread, :on_pool] type @param [Channel] channel @param [Environment, Module] environment @param [#to_s] name of the actor @param [ExecutorService] executor of the actor @return [Pid] @see Concurrent::ErlangActor::Environment#spawn

# File lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb, line 492
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) click to toggle source

Same as {Environment#terminate}, but it requires pid. @param [Pid] pid @param [Object, :normal, :kill] reason @return [true]

# File lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb, line 509
def terminate_actor(pid, reason)
  if reason == :kill
    pid.tell Kill.new(nil)
  else
    pid.tell Terminate.new(nil, reason, false)
  end
  true
end