pub struct ActorRegistry {
actors: HashMap<String, Box<dyn Actor + Send>>,
new_actors: RefCell<Vec<Box<dyn Actor + Send>>>,
old_actors: RefCell<Vec<String>>,
script_actors: RefCell<HashMap<String, String>>,
shareable: Option<Arc<Mutex<ActorRegistry>>>,
next: Cell<u32>,
start_stamp: CrossProcessInstant,
}
Expand description
A list of known, owned actors.
Fields§
§actors: HashMap<String, Box<dyn Actor + Send>>
§new_actors: RefCell<Vec<Box<dyn Actor + Send>>>
§old_actors: RefCell<Vec<String>>
§script_actors: RefCell<HashMap<String, String>>
§next: Cell<u32>
§start_stamp: CrossProcessInstant
Implementations§
Source§impl ActorRegistry
impl ActorRegistry
Sourcepub fn new() -> ActorRegistry
pub fn new() -> ActorRegistry
Create an empty registry.
pub(crate) fn cleanup(&self, stream_id: StreamId)
Creating shareable registry
Get shareable registry through threads
Sourcepub fn start_stamp(&self) -> CrossProcessInstant
pub fn start_stamp(&self) -> CrossProcessInstant
Get start stamp when registry was started
pub fn register_script_actor(&self, script_id: String, actor: String)
pub fn script_to_actor(&self, script_id: String) -> String
pub fn script_actor_registered(&self, script_id: String) -> bool
pub fn actor_to_script(&self, actor: String) -> String
Sourcepub fn new_name(&self, prefix: &str) -> String
pub fn new_name(&self, prefix: &str) -> String
Create a unique name based on a monotonically increasing suffix
Sourcepub(crate) fn register(&mut self, actor: Box<dyn Actor + Send>)
pub(crate) fn register(&mut self, actor: Box<dyn Actor + Send>)
Add an actor to the registry of known actors that can receive messages.
pub(crate) fn register_later(&self, actor: Box<dyn Actor + Send>)
Sourcepub fn find_mut<'a, T: Any>(&'a mut self, name: &str) -> &'a mut T
pub fn find_mut<'a, T: Any>(&'a mut self, name: &str) -> &'a mut T
Find an actor by registered name
Sourcepub(crate) fn handle_message(
&mut self,
msg: &Map<String, Value>,
stream: &mut TcpStream,
stream_id: StreamId,
) -> Result<(), ()>
pub(crate) fn handle_message( &mut self, msg: &Map<String, Value>, stream: &mut TcpStream, stream_id: StreamId, ) -> Result<(), ()>
Attempt to process a message as directed by its to
property. If the actor is not
found or does not indicate that it knew how to process the message, ignore the failure.
pub fn drop_actor(&mut self, name: String)
pub fn drop_actor_later(&self, name: String)
Auto Trait Implementations§
impl !Freeze for ActorRegistry
impl !RefUnwindSafe for ActorRegistry
impl Send for ActorRegistry
impl !Sync for ActorRegistry
impl Unpin for ActorRegistry
impl !UnwindSafe for ActorRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert