Add "KeepAlive" for when a driver is still getting ready to expose an Entity but hasn't done so yet.
This commit is contained in:
parent
bbaacd3038
commit
090ac8780f
|
@ -347,7 +347,7 @@ pub struct ActorRef {
|
||||||
|
|
||||||
/// A combination of an [`ActorRef`] with a [`FacetId`], acting as a capability to enter the
|
/// A combination of an [`ActorRef`] with a [`FacetId`], acting as a capability to enter the
|
||||||
/// execution context of a facet from a linked task.
|
/// execution context of a facet from a linked task.
|
||||||
#[derive(Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FacetRef {
|
pub struct FacetRef {
|
||||||
pub actor: ActorRef,
|
pub actor: ActorRef,
|
||||||
pub facet_id: FacetId,
|
pub facet_id: FacetId,
|
||||||
|
@ -1986,6 +1986,9 @@ impl Facet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct KeepAlive(Option<Arc<Mailbox>>);
|
||||||
|
|
||||||
impl ActorRef {
|
impl ActorRef {
|
||||||
/// Uses an internal mutex to access the internal state: takes the
|
/// Uses an internal mutex to access the internal state: takes the
|
||||||
/// lock, calls `f` with the internal state, releases the lock,
|
/// lock, calls `f` with the internal state, releases the lock,
|
||||||
|
@ -2005,6 +2008,16 @@ impl ActorRef {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a [`KeepAlive`] for (usually temporarily) ensuring an [Actor] does not get
|
||||||
|
/// garbage-collected due to no references to its [Mailbox] being held. (It may of course
|
||||||
|
/// be terminated for other reasons.)
|
||||||
|
pub fn keep_alive(&self) -> KeepAlive {
|
||||||
|
KeepAlive(self.access(|s| match s {
|
||||||
|
ActorState::Terminated { .. } => None,
|
||||||
|
ActorState::Running(ra) => Some(ra.mailbox()),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
fn facet_ref(&self, facet_id: FacetId) -> FacetRef {
|
fn facet_ref(&self, facet_id: FacetId) -> FacetRef {
|
||||||
FacetRef {
|
FacetRef {
|
||||||
actor: self.clone(),
|
actor: self.clone(),
|
||||||
|
|
Loading…
Reference in New Issue