Struct robots::actors::actor_system::ActorSystem
[−]
[src]
pub struct ActorSystem { /* fields omitted */ }
The actor system is the struct that manages:
- The creation of the root actors.
- The consumer threads.
- Scheduling the actors.
It needs to be instantiated once at the beggining of the application. Then we need to specify the number of consumer threads that will be allocated.
Calling shutdown
, will drop all the actors and terminate the consumer threads.
Note that it will shut down the system even if some actors have still messages to handle.
Methods
impl ActorSystem
[src]
fn new(name: String) -> ActorSystem
[src]
Creates a new ActorSystem.
Note that one thread is started.
fn actor_of(&self, props: Arc<ActorFactory>, name: String) -> ActorRef
[src]
Spawns an Actor created using the Props given for the user.
fn system_actor_of(&self, props: Arc<ActorFactory>, name: String) -> ActorRef
[src]
Spawns an Actor created using the Props given for the system.
fn shutdown(&self)
[src]
Shuts the actor system down.
It will terminate all the actors (whether they still have messages to handle or not) and then terminate the consumer threads.
fn enqueue_actor(&self, actor_ref: ActorRef)
[src]
Enqueues the given ActorRef in the queue of ActorRef with message to handle.
fn spawn_thread(&self)
[src]
Spawns a thread that will have ActorRef handle their messages.
This thread can be terminated by calling terminate_thread
.
fn terminate_thread(&self)
[src]
Kills a consumer thread.
fn spawn_threads(&self, n: u32)
[src]
Spawns n consumer threads.
fn terminate_threads(&self, n: u32)
[src]
Kills n consumer threads.
fn name_resolver(&self) -> ActorRef
[src]
Gives the ActorRef of the name resolver actor.
fn tell<M: Message>(&self, to: ActorRef, message: M)
[src]
Sends a message to the given actor.
The sender of the message is the user_actor, thus this expects that no answer will be given.
fn ask<M: Message>(&self, to: ActorRef, message: M, name: String) -> ActorRef
[src]
Creates a Future that will send the message to the targetted actor.
The father of this Future is the user_actor.
fn extract_result<M: Message>(&self, future: ActorRef) -> M
[src]
Extracts the result from a Future.
This is not supposed to be used a lot as this is a synchronous call (if an actor wants to get the result of a fututure it should use forward_result instead).
The extraction creates an Extractor actor whose father is the user_actor.
Trait Implementations
impl Clone for ActorSystem
[src]
fn clone(&self) -> ActorSystem
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more