[−][src]Struct axiom::actors::ActorSystem
An actor system that contains and manages the actors spawned inside it.
Methods
impl ActorSystem
[src]
pub fn create(config: ActorSystemConfig) -> ActorSystem
[src]
Creates an actor system with the given config. The user should benchmark how many slots in the work channel, the number of threads they need and so on in order to satisfy the requirements of the software they are creating.
pub fn init_current(&self)
[src]
Initialises this actor system to use for the current thread which is necessary if the user wishes to call into the actor system from another thread. Note that this can be called only once per thread; on the second call it will panic.
pub fn current() -> ActorSystem
[src]
Fetches a clone of a reference of the actor system for the current thread.
pub fn trigger_shutdown(&self)
[src]
Triggers a shutdown but doesn't wait for threads to stop.
pub fn await_shutdown(&self)
[src]
Awaits for the actor system to be shutdown using a relatively CPU minimal condvar as a signalling mechanism. This function will block until all actor system threads have stopped.
pub fn trigger_and_await_shutdown(&self)
[src]
Triggers a shutdown of the system and returns only when all threads have joined.
pub fn sent(&self) -> usize
[src]
Returns the total number of times actors have been sent to the work channel.
pub fn received(&self) -> usize
[src]
Returns the total number of times actors have been processed from the work channel.
pub fn pending(&self) -> usize
[src]
Returns the total number of actors that are currently pending in the work channel.
pub fn spawn<F, State>(&self, state: State, processor: F) -> ActorId where
State: Send + Sync + 'static,
F: Processor<State> + 'static,
[src]
State: Send + Sync + 'static,
F: Processor<State> + 'static,
Spawns a new unnamed actor on the system
using the given starting state
for the actor
and the given processor
function that will be used to process actor messages. The
spawned actor will use default values for the actor's config.
Examples
use axiom::actors::*; use axiom::message::*; use std::sync::Arc; let system = ActorSystem::create(ActorSystemConfig::default()); system.init_current(); let aid = system.spawn( 0 as usize, |_state: &mut usize, _aid: ActorId, _message: &Message| Status::Processed, ); aid.send(Message::new(11));
pub fn spawn_named<F, State>(
&self,
name: &str,
state: State,
processor: F
) -> Result<ActorId, ActorError> where
State: Send + Sync + 'static,
F: Processor<State> + 'static,
[src]
&self,
name: &str,
state: State,
processor: F
) -> Result<ActorId, ActorError> where
State: Send + Sync + 'static,
F: Processor<State> + 'static,
Spawns a new named actor on the system
using the given starting state
for the actor
and the given processor
function that will be used to process actor messages.
If the name
is already registered then this function will return an [std::Result::Err
]
with the value ActorError::NameAlreadyUsed
containing the name attempted to be
registered.
Examples
use axiom::actors::*; use axiom::message::*; use std::sync::Arc; let system = ActorSystem::create(ActorSystemConfig::default()); system.init_current(); let aid = system.spawn_named( "alpha", 0 as usize, |_state: &mut usize, _aid: ActorId, message: &Message| Status::Processed, );
pub fn stop(&self, aid: ActorId)
[src]
Stops an actor by shutting down its channels and removing it from the actors list and telling the actor id to not allow messages to be sent to the actor since the receiving side of the actor is gone.
This is something that should rarely be called from the outside as it is much better to
send the actor a SystemMsg::Stop
message and allow it to stop gracefully.
pub fn is_alive(&self, aid: &ActorId) -> bool
[src]
Checks to see if the actor with the given ActorId
is alive within this actor system.
pub fn find_aid_by_uuid(&self, uuid: &Uuid) -> Option<ActorId>
[src]
Look up an ActorId
by the unique UUID of the actor and either returns the located
aid
in a Option::Some
or Option::None
if not found.
pub fn find_aid_by_name(&self, name: &str) -> Option<ActorId>
[src]
Look up an ActorId
by the user assigned name of the actor and either returns the
located aid
in a Option::Some
or Option::None
if not found.
pub fn monitor(&self, monitoring: &ActorId, monitored: &ActorId)
[src]
Adds a monitor so that monitoring
will be informed if monitored
stops.
Trait Implementations
impl Clone for ActorSystem
[src]
fn clone(&self) -> ActorSystem
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for ActorSystem
[src]
Auto Trait Implementations
impl Sync for ActorSystem
impl Unpin for ActorSystem
impl Send for ActorSystem
impl !UnwindSafe for ActorSystem
impl !RefUnwindSafe for ActorSystem
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,