pub struct RemoteActorRegistry { /* private fields */ }Expand description
A registry of actors in the current process which can receive RemoteMessages.
The registry is a cheaply-cloneable concurrent map shared between a Node
and all of its sessions. It lets sessions route inbound RemoteMessages to the proper
actor in the same process.
An actor which implements the RemoteActor trait will be
automatically registered in a Node’s registry when its address is encoded
as a RemoteMessage for the first time. Users can also manually register an actor with
a Node’s AddActor command.
Implementations§
Source§impl RemoteActorRegistry
impl RemoteActorRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new empty RemoteActorRegistry.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Constructs a new empty RemoteActorRegistry with the specified capacity.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of actors the registry can hold without reallocating.
Locking behavior: May deadlock if called when holding a mutable reference into the registry.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of actors currently in the registry.
Locking behavior: May deadlock if called when holding a mutable reference into the registry.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the registry contains no actors.
Locking behavior: May deadlock if called when holding a mutable reference into the registry.
Sourcepub fn retain<F>(&self, predicate: F)
pub fn retain<F>(&self, predicate: F)
Retains only the actors for which the predicate returns true.
Locking behavior: May deadlock if called when holding any sort of reference into the registry.
Sourcepub fn get(&self, index: u64) -> Option<Recipient<RemoteMessage>>
pub fn get(&self, index: u64) -> Option<Recipient<RemoteMessage>>
Returns an actor as a Recipient<RemoteMessage> corresponding to the given index.
If the actor’s mailbox is closed, this method removes it and returns None. This is
different from the behavior of get on a normal HashMap.
Locking behavior: May deadlock if called when holding any sort of reference into the registry.
Sourcepub fn contains_index(&self, index: u64) -> bool
pub fn contains_index(&self, index: u64) -> bool
Returns true if the registry contains an actor for the given index.
Locking behavior: May deadlock if called when holding a mutable reference into the registry.
Sourcepub fn remove(&self, index: u64) -> Option<Recipient<RemoteMessage>>
pub fn remove(&self, index: u64) -> Option<Recipient<RemoteMessage>>
Removes an actor by its index, returning the actor as a Recipient<RemoteMessage> if it
was present in the registry.
Locking behavior: May deadlock if called when holding any sort of reference into the registry.
Sourcepub fn insert<A>(&self, actor: A) -> bool
pub fn insert<A>(&self, actor: A) -> bool
Inserts a new actor keyed by its index.
If the registry did not have this actor present, true is returned. If the registry did
have this actor present, false is returned and the registry is not modified. This is
different from the behavior of insert on a normal HashMap.
Re-registering the same address is a cheap lookup-no-op.
Locking behavior: May deadlock if called when holding any sort of reference into the registry.
Trait Implementations§
Source§impl Clone for RemoteActorRegistry
impl Clone for RemoteActorRegistry
Source§fn clone(&self) -> RemoteActorRegistry
fn clone(&self) -> RemoteActorRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more