macro_rules! actor_in_slab {
($self:ident.$children:ident, $cx:expr, $type:ident :: $init:ident($($x:expr),* $(,)? )) => { ... };
($self:ident.$children:ident, $cx:expr, <$type:ty> :: $init:ident($($x:expr),* $(,)? )) => { ... };
($self:ident.$children:ident, $cx:expr, $type:ident :: $init:ident($($x:expr),* $(,)? ), $notify:expr) => { ... };
($self:ident.$children:ident, $cx:expr, <$type:ty> :: $init:ident($($x:expr),* $(,)? ), $notify:expr) => { ... };
}
Expand description
Create a new actor in an ActorOwnSlab
The new actor is created and its ActorOwn
reference is stored
in the provided ActorOwnSlab
. The termination notification
handler is set up to remove the reference from the slab when the
actor terminates. So this takes care of all the child actor
housekeeping for simple cases. See ActorOwnSlab
for notes on
more complicated cases.
So assuming self.children
is your ActorOwnSlab
instance, the
call will take one of these forms:
ⓘ
let actor = actor_in_slab!(self.children, cx, Type::init(args...));
let actor = actor_in_slab!(self.children, cx, <path::Type>::init(args...));
If you need to monitor failures, then add a Ret<StopCause>
instance to the end of the macro arguments. For example:
ⓘ
let actor = actor_in_slab!(
self.children, cx, <path::Type>::init(args...),
ret_some_to!([cx], |this, cx, cause: StopCause| {
...error handling...
}));
Implemented using ActorOwnSlab::add
.