#[macro_export]
macro_rules! CX {
() => { &mut $crate::Cx<'_, Self> };
($other:ty) => { &mut $crate::Cx<'_, $other> };
}
#[doc(hidden)]
#[macro_export]
macro_rules! indices {
( $cb:ident $( $args:tt )* ) =>
{ $crate::$cb!( $($args)* ) };
( [ ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* []) };
( [ $a:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 ]) };
( [ $a:tt $b:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 ]) };
( [ $a:tt $b:tt $c:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 ]) };
( [ $a:tt $b:tt $c:tt $d:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt $h:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 7 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt $h:tt $i:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 7 8 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt $h:tt $i:tt $j:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 7 8 9 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt $h:tt $i:tt $j:tt $k:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 7 8 9 10 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt $h:tt $i:tt $j:tt $k:tt $l:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 7 8 9 10 11 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt $h:tt $i:tt $j:tt $k:tt $l:tt $m:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt $h:tt $i:tt $j:tt $k:tt $l:tt $m:tt $n:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt $h:tt $i:tt $j:tt $k:tt $l:tt $m:tt $n:tt $o:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ]) };
( [ $a:tt $b:tt $c:tt $d:tt $e:tt $f:tt $g:tt $h:tt $i:tt $j:tt $k:tt $l:tt $m:tt $n:tt $o:tt $p:tt ] $($rest:tt)* ) =>
{ $crate::indices!($($rest)* [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ]) };
( $($rest:tt)* ) =>
{ std::compile_error!("Too many arguments in call"); }
}
#[cfg(test)]
#[doc(hidden)]
#[macro_export]
macro_rules! COVERAGE {
($name:ident) => {
$crate::test::macro_coverage::$name();
};
}
#[cfg(not(test))]
#[doc(hidden)]
#[macro_export]
macro_rules! COVERAGE {
($name:ident) => {};
}
#[macro_export]
macro_rules! actor {
($core:expr, $type:ident :: $init:ident($($x:expr),* $(,)? ), $notify:expr) => {{
$crate::COVERAGE!(actor_0);
let notify = $notify;
let parid = $core.access_log_id();
let core = $core.access_core();
let actor = $crate::ActorOwn::<$type>::new(core, notify, parid);
$crate::call!([actor], <$type>::$init($($x),*));
actor
}};
($core:expr, <$type:ty> :: $init:ident($($x:expr),* $(,)? ), $notify:expr) => {{
$crate::COVERAGE!(actor_1);
let notify = $notify;
let parid = $core.access_log_id();
let core = $core.access_core();
let actor = $crate::ActorOwn::<$type>::new(core, notify, parid);
$crate::call!([actor], <$type>::$init($($x),*));
actor
}};
}
#[macro_export]
macro_rules! actor_new {
($core:expr, $type:ty, $notify:expr) => {{
$crate::COVERAGE!(actor_new);
let notify = $notify;
let parid = $core.access_log_id();
let core = $core.access_core();
$crate::ActorOwn::<$type>::new(core, notify, parid) }};
}
#[macro_export]
macro_rules! actor_of_trait {
($core:expr, $trait:ident, $type:ident :: $init:ident($($x:expr),* $(,)? ), $notify:expr) => {{
$crate::COVERAGE!(actor_2);
let notify = $notify;
let parid = $core.access_log_id();
let core = $core.access_core();
let actor = $crate::ActorOwn::<$trait>::new(core, notify, parid);
$crate::call!([actor], <$type>::$init($($x),*));
actor
}};
($core:expr, $trait:ident, <$type:ty> :: $init:ident($($x:expr),* $(,)? ), $notify:expr) => {{
$crate::COVERAGE!(actor_3);
let notify = $notify;
let parid = $core.access_log_id();
let core = $core.access_core();
let actor = $crate::ActorOwn::<$trait>::new(core, notify, parid);
$crate::call!([actor], <$type>::$init($($x),*));
actor
}};
}
#[macro_export]
macro_rules! actor_in_slab {
($self:ident.$children:ident, $cx:expr, $type:ident :: $init:ident($($x:expr),* $(,)? )) => {{
$crate::COVERAGE!(actor_in_slab_0);
$crate::actor_in_slab!($self.$children, $cx, <$type>::$init($($x),*), $crate::Ret::new(|_| {}))
}};
($self:ident.$children:ident, $cx:expr, <$type:ty> :: $init:ident($($x:expr),* $(,)? )) => {{
$crate::COVERAGE!(actor_in_slab_1);
$crate::actor_in_slab!($self.$children, $cx, <$type>::$init($($x),*), $crate::Ret::new(|_| {}))
}};
($self:ident.$children:ident, $cx:expr, $type:ident :: $init:ident($($x:expr),* $(,)? ), $notify:expr) => {{
$crate::COVERAGE!(actor_in_slab_2);
$crate::actor_in_slab!($self.$children, $cx, <$type>::$init($($x),*), $notify)
}};
($self:ident.$children:ident, $cx:expr, <$type:ty> :: $init:ident($($x:expr),* $(,)? ), $notify:expr) => {{
$crate::COVERAGE!(actor_in_slab_3);
let notify = $notify;
let parent = $cx.this().clone();
let core = $cx.access_core();
let actor = $self.$children.add(core, parent, |this| &mut this.$children, notify);
$crate::call!([actor], <$type>::$init($($x),*));
actor
}};
}
#[macro_export]
macro_rules! query {
([$actor:expr, $stakker:expr], $method:ident( $($x:expr),* $(,)? )) => {{
$crate::COVERAGE!(query_0);
$actor.query($stakker, |this, cx| this.$method(cx, $($x),*))
}}
}
#[doc(hidden)]
#[macro_export]
macro_rules! generic_call {
($handler:ident $hargs:tt $access:ident;
[$cx:expr], |$this:pat, $cxid:pat| $body:expr) => {{
$crate::COVERAGE!(generic_call_0);
let cb = move |$this: &mut Self, $cxid: &mut $crate::Cx<'_, Self>| $body;
let cx: &mut $crate::Cx<'_, Self> = $cx; let this = cx.this().clone();
let core = $cx.access_core();
$crate::$handler!($hargs core; move |s| this.apply(s, cb));
}};
($handler:ident $hargs:tt $access:ident;
[$core:expr], |$stakker:pat| $body:expr) => {{
$crate::COVERAGE!(generic_call_1);
let core = $core.$access(); let cb = move |$stakker : &mut $crate::Stakker| $body;
$crate::$handler!($hargs core; cb);
}};
($handler:ident $hargs:tt $access:ident;
[$cx:expr], move | $($x:tt)*) => {{
std::compile_error!("Do not add `move` to closures as they get an implicit `move` anyway");
}};
($handler:ident $hargs:tt $access:ident;
[$actor_or_cx:expr], $($x:tt)+) => {{
$crate::generic_call!($handler $hargs $access; [$actor_or_cx, $actor_or_cx], $($x)+)
}};
($handler:ident $hargs:tt $access:ident;
[$actor:expr, $core:expr], $method:ident ( $($x:expr),* $(,)? )) => {{
$crate::COVERAGE!(generic_call_2);
let actor = $actor.access_actor().clone(); let _args = ( $($x,)* ); let access = $core.$access();
$crate::indices!([$(($x))*] generic_call_ready $handler $hargs access; actor _args $method)
}};
($handler:ident $hargs:tt $access:ident;
[$actor:expr, $core:expr], $type:ident :: $method:ident ( $($x:expr),* $(,)? )) => {{
$crate::COVERAGE!(generic_call_3);
let actor = $actor.access_actor().clone(); let _args = ( $($x,)* ); let access = $core.$access();
$crate::indices!([$(($x))*] generic_call_prep $handler $hargs access; actor _args <$type> $method)
}};
($handler:ident $hargs:tt $access:ident;
[$actor:expr, $core:expr], < $type:ty > :: $method:ident ( $($x:expr),* $(,)? )) => {{
$crate::COVERAGE!(generic_call_4);
let actor = $actor.access_actor().clone(); let _args = ( $($x,)* ); let access = $core.$access();
$crate::indices!([$(($x))*] generic_call_prep $handler $hargs access; actor _args <$type> $method)
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! generic_call_ready {
($handler:ident $hargs:tt $core:ident; $actor:ident $args:ident $method:ident [$($xi:tt)*]) => {
$crate::$handler!($hargs $core; move |s| $actor.apply(s, move |o, c| o.$method(c $(, $args.$xi)*)))
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! generic_call_prep {
($handler:ident $hargs:tt $core:ident; $actor:ident $args:ident <$atyp:ty> $method:ident [$($xi:tt)*]) => {
$crate::$handler!($hargs $core; move |s| $actor.apply_prep(s, move |c| <$atyp>::$method(c $(, $args.$xi)*)))
}
}
#[macro_export]
macro_rules! call {
( $($x:tt)+ ) => {{
$crate::COVERAGE!(call_0);
$crate::generic_call!(call_aux () access_deferrer; $($x)+);
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! call_aux {
(() $defer:ident; $cb:expr) => {{
$crate::COVERAGE!(call_1);
$defer.defer($cb);
}};
}
#[macro_export]
macro_rules! lazy {
( $($x:tt)+ ) => {{
$crate::COVERAGE!(lazy_0);
$crate::generic_call!(lazy_aux () access_core; $($x)+); }};
}
#[doc(hidden)]
#[macro_export]
macro_rules! lazy_aux {
(() $core:ident; $cb:expr) => {{
$crate::COVERAGE!(lazy_1);
$core.lazy($cb);
}};
}
#[macro_export]
macro_rules! idle {
( $($x:tt)+ ) => {{
$crate::COVERAGE!(idle_0);
$crate::generic_call!(idle_aux () access_core; $($x)+); }};
}
#[doc(hidden)]
#[macro_export]
macro_rules! idle_aux {
(() $core:ident; $cb:expr) => {{
$crate::COVERAGE!(idle_1);
$core.idle($cb);
}};
}
#[macro_export]
macro_rules! after {
( $dur:expr, $($x:tt)+ ) => {{
$crate::COVERAGE!(after_0);
let dur: Duration = $dur;
$crate::generic_call!(after_aux (dur) access_core; $($x)+) }};
}
#[doc(hidden)]
#[macro_export]
macro_rules! after_aux {
(($dur:ident) $core:ident; $cb:expr) => {{
$crate::COVERAGE!(after_1);
$core.after($dur, $cb);
}};
}
#[macro_export]
macro_rules! at {
( $inst:expr, $($x:tt)+ ) => {{
$crate::COVERAGE!(at_0);
let inst: std::time::Instant = $inst;
$crate::generic_call!(at_aux (inst) access_core; $($x)+) }};
}
#[doc(hidden)]
#[macro_export]
macro_rules! at_aux {
(($inst:ident) $core:ident; $cb:expr) => {{
$crate::COVERAGE!(at_1);
$core.timer_add($inst, $cb)
}};
}
#[macro_export]
macro_rules! timer_max {
( $var:expr, $inst:expr, $($x:tt)+ ) => {{
$crate::COVERAGE!(timer_max_0);
let var: &mut $crate::MaxTimerKey = $var;
let inst: std::time::Instant = $inst;
$crate::generic_call!(timer_max_aux (var, inst) access_core; $($x)+) }};
}
#[doc(hidden)]
#[macro_export]
macro_rules! timer_max_aux {
(($var:ident, $inst:ident) $core:ident; $cb:expr) => {{
$crate::COVERAGE!(timer_max_1);
if !$core.timer_max_upd(*$var, $inst) {
*$var = $core.timer_max_add($inst, $cb);
}
}};
}
#[macro_export]
macro_rules! timer_min {
( $var:expr, $inst:expr, $($x:tt)+ ) => {{
$crate::COVERAGE!(timer_min_0);
let var: &mut $crate::MinTimerKey = $var;
let inst: std::time::Instant = $inst;
$crate::generic_call!(timer_min_aux (var, inst) access_core; $($x)+) }};
}
#[doc(hidden)]
#[macro_export]
macro_rules! timer_min_aux {
(($var:ident, $inst:ident) $core:ident; $cb:expr) => {{
$crate::COVERAGE!(timer_min_1);
if !$core.timer_min_upd(*$var, $inst) {
*$var = $core.timer_min_add($inst, $cb);
}
}};
}
#[macro_export]
macro_rules! fwd {
([ $fwd:expr ], $arg:expr) => {{
$crate::COVERAGE!(fwd_0);
$fwd.fwd($arg);
}};
([ $fwd:expr ] $(, $arg:expr)*) => {{
$crate::COVERAGE!(fwd_1);
$fwd.fwd(( $($arg ,)* ));
}};
}
#[macro_export]
macro_rules! ret {
([ $ret:expr ], $arg:expr) => {{
$crate::COVERAGE!(ret_0);
$ret.ret($arg);
}};
([ $ret:expr ] $(, $arg:expr)*) => {{
$crate::COVERAGE!(ret_1);
$ret.ret(( $($arg ,)* ));
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! generic_fwd {
($handler:ident; [$actor:expr], $method:ident ( $($x:expr),* ) as ( $($t:ty),* )) => {{
$crate::COVERAGE!(generic_fwd_0);
let actor = $actor.access_actor().clone(); let _args = ( $($x,)* );
$crate::indices!([$(($x))*] [$(($t))*] generic_fwd_ready $handler actor _args ($($t,)*) $method)
}};
($handler:ident; [$actor:expr], $type:ident::$method:ident ( $($x:expr),* ) as ( $($t:ty),* )) => {{
$crate::COVERAGE!(generic_fwd_1);
let actor = $actor.access_actor().clone(); let _args = ( $($x,)* );
$crate::indices!([$(($x))*] [$(($t))*] generic_fwd_prep $handler actor _args ($($t,)*) <$type> $method)
}};
($handler:ident; [$actor:expr], <$type:ty>::$method:ident ( $($x:expr),* ) as ( $($t:ty),* )) => {{
$crate::COVERAGE!(generic_fwd_2);
let actor = $actor.access_actor().clone(); let _args = ( $($x,)* );
$crate::indices!([$(($x))*] [$(($t))*] generic_fwd_prep $handler actor _args ($($t,)*) <$type> $method)
}};
($handler:ident; [$cx:expr], |$this:pat, $cxid:pat, $arg:ident : $t:ty| $($body:tt)+) => {{
$crate::COVERAGE!(generic_fwd_3);
let cx: &mut $crate::Cx<'_, _> = $cx; let actor = cx.this().clone();
$crate::$handler!(ready actor;
move |$this, $cxid, $arg: $t| $($body)*;
std::compile_error!("`ret_to!` with a closure requires a single Option argument"))
}};
($handler:ident; [$cx:expr], |$this:pat, $cxid:pat $(, $arg:ident : $t:ty)*| $($body:tt)+) => {{
$crate::COVERAGE!(generic_fwd_4);
let cx: &mut $crate::Cx<'_, _> = $cx; let actor = cx.this().clone();
$crate::$handler!(ready actor;
move |$this, $cxid, ($($arg),*): ($($t),*)| $($body)*;
std::compile_error!("`ret_to!` with a closure requires a single Option argument"))
}};
($handler:ident; [$cx:expr], move | $($x:tt)*) => {{
std::compile_error!("Do not add `move` to closures as they get an implicit `move` anyway");
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! generic_fwd_ready {
($handler:ident $actor:ident $args:ident ($t:ty,) $method:ident [$($xi:tt)*] [$($ti:tt)*]) => {{
$crate::COVERAGE!(generic_fwd_5);
$crate::$handler!(ready $actor;
move |a, cx, m: $t| a.$method(cx $(, $args.$xi)* , m);
move |a, cx, m: Option<$t>| a.$method(cx $(, $args.$xi)* , m))
}};
($handler:ident $actor:ident $args:ident ($($t:ty,)*) $method:ident [$($xi:tt)*] [$($ti:tt)*]) => {{
$crate::COVERAGE!(generic_fwd_6);
$crate::$handler!(ready $actor;
move |a, cx, _m: ($($t,)*)| a.$method(cx $(, $args.$xi)* $(, _m.$ti)*);
move |a, cx, m: Option<($($t,)*)>| a.$method(cx $(, $args.$xi)*, m))
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! generic_fwd_prep {
($handler:ident $actor:ident $args:ident ($t:ty,) <$atyp:ty> $method:ident [$($xi:tt)*] [$($ti:tt)*]) => {{
$crate::COVERAGE!(generic_fwd_7);
$crate::$handler!(prep $actor;
move |cx, m: $t| <$atyp>::$method(cx $(, $args.$xi)* , m);
move |cx, m: Option<$t>| <$atyp>::$method(cx $(, $args.$xi)* , m))
}};
($handler:ident $actor:ident $args:ident ($($t:ty,)*) <$atyp:ty> $method:ident [$($xi:tt)*] [$($ti:tt)*]) => {{
$crate::COVERAGE!(generic_fwd_8);
$crate::$handler!(prep $actor;
move |cx, _m: ($($t,)*)| <$atyp>::$method(cx $(, $args.$xi)* $(, _m.$ti)*);
move |cx, m: Option<($($t,)*)>| <$atyp>::$method(cx $(, $args.$xi)*, m))
}};
}
#[macro_export]
macro_rules! fwd_to {
($($x:tt)*) => {{
$crate::COVERAGE!(fwd_to_0);
$crate::generic_fwd!(fwd_to_aux; $($x)*)
}}
}
#[doc(hidden)]
#[macro_export]
macro_rules! fwd_to_aux {
(ready $actor:ident; $cb:expr; $cb2:expr) => {{
$crate::COVERAGE!(fwd_to_1);
$crate::Fwd::to_actor($actor, $cb)
}};
(prep $actor:ident; $cb:expr; $cb2:expr) => {{
$crate::COVERAGE!(fwd_to_2);
$crate::Fwd::to_actor_prep($actor, $cb)
}};
}
#[macro_export]
macro_rules! fwd_panic {
($arg:expr) => {{
$crate::COVERAGE!(fwd_panic_0);
$crate::Fwd::panic($arg)
}};
}
#[macro_export]
macro_rules! fwd_do {
($cb:expr) => {{
$crate::COVERAGE!(fwd_do_0);
$crate::Fwd::new($cb)
}};
}
#[macro_export]
macro_rules! fwd_nop {
() => {{
$crate::COVERAGE!(fwd_nop_0);
$crate::Fwd::new(|_| {})
}};
}
#[macro_export]
macro_rules! ret_to {
([$cx:expr], |$this:pat, $cxid:pat, $arg:ident : Option<$t:ty>| $($body:tt)+) => {{
$crate::COVERAGE!(ret_to_0);
let cx: &mut $crate::Cx<'_, _> = $cx; let actor = cx.this().clone();
$crate::Ret::to_actor(actor, move |$this, $cxid, $arg: Option<$t>| $($body)*)
}};
([$cx:expr], move | $($x:tt)*) => {{
std::compile_error!("Do not add `move` to closures as they get an implicit `move` anyway");
}};
($($x:tt)*) => {{
$crate::COVERAGE!(ret_to_1);
$crate::generic_fwd!(ret_to_aux; $($x)*)
}}
}
#[doc(hidden)]
#[macro_export]
macro_rules! ret_to_aux {
(ready $actor:ident; $cb:expr; $cb2:expr) => {{
$crate::COVERAGE!(ret_to_2);
$crate::Ret::to_actor($actor, $cb2)
}};
(prep $actor:ident; $cb:expr; $cb2:expr) => {{
$crate::COVERAGE!(ret_to_3);
$crate::Ret::to_actor_prep($actor, $cb2)
}};
}
#[macro_export]
macro_rules! ret_some_to {
($($x:tt)*) => {{
$crate::COVERAGE!(ret_some_to_0);
$crate::generic_fwd!(ret_some_to_aux; $($x)*)
}}
}
#[doc(hidden)]
#[macro_export]
macro_rules! ret_some_to_aux {
(ready $actor:ident; $cb:expr; $cb2:expr) => {{
$crate::COVERAGE!(ret_some_to_1);
$crate::Ret::some_to_actor($actor, $cb)
}};
(prep $actor:ident; $cb:expr; $cb2:expr) => {{
$crate::COVERAGE!(ret_some_to_2);
$crate::Ret::some_to_actor_prep($actor, $cb)
}};
}
#[macro_export]
macro_rules! ret_do {
($cb:expr) => {{
$crate::COVERAGE!(ret_do_0);
$crate::Ret::new($cb)
}};
}
#[macro_export]
macro_rules! ret_some_do {
($cb:expr) => {{
$crate::COVERAGE!(ret_some_do_0);
let cb = $cb;
$crate::Ret::new(move |m| {
if let Some(m) = m {
cb(m);
}
})
}};
}
#[macro_export]
macro_rules! ret_panic {
($arg:expr) => {{
$crate::COVERAGE!(ret_panic_0);
$crate::Ret::panic($arg)
}};
}
#[macro_export]
macro_rules! ret_nop {
() => {{
$crate::COVERAGE!(ret_nop_0);
$crate::Ret::new(|_| {})
}};
}
#[macro_export]
macro_rules! ret_shutdown {
($core:expr) => {{
$crate::COVERAGE!(ret_shutdown_0);
let core = $core.access_core();
let deferrer = core.deferrer();
$crate::Ret::new(move |m| {
if let Some(cause) = m {
deferrer.defer(|s| s.shutdown(cause));
} else {
deferrer.defer(|s| s.shutdown($crate::StopCause::Dropped));
}
})
}};
}
#[macro_export]
macro_rules! ret_fail {
($cx:expr, $msg:literal) => {{
$crate::COVERAGE!(ret_fail_0);
let cx: &mut $crate::Cx<'_, _> = $cx;
let actor = cx.this().clone();
$crate::Ret::to_actor(actor, move |_, cx, _| cx.fail_str($msg))
}};
($cx:expr, $fmt:literal $(, $arg:expr)*) => {{
$crate::COVERAGE!(ret_fail_1);
let message = format!($fmt $(, $arg)*);
let cx: &mut $crate::Cx<'_, _> = $cx;
let actor = cx.this().clone();
$crate::Ret::to_actor(actor, move |_, cx, _| cx.fail_string(message))
}};
($cx:expr, $error:expr) => {{
$crate::COVERAGE!(ret_fail_2);
let error = $error;
let cx: &mut $crate::Cx<'_, _> = $cx;
let actor = cx.this().clone();
$crate::Ret::to_actor(actor, move |_, cx, _| cx.fail(error))
}};
}
#[macro_export]
macro_rules! ret_failthru {
($cx:expr, $msg:literal) => {{
$crate::COVERAGE!(ret_failthru_0);
let cx: &mut $crate::Cx<'_, _> = $cx;
let actor = cx.this().clone();
$crate::Ret::some_to_actor(actor, move |_, cx, m: StopCause| {
if matches!(m, StopCause::Lost | StopCause::Failed(_)) {
cx.fail_str($msg);
}
})
}};
($cx:expr, $fmt:literal $(, $arg:expr)*) => {{
$crate::COVERAGE!(ret_failthru_1);
let message = format!($fmt $(, $arg)*);
let cx: &mut $crate::Cx<'_, _> = $cx;
let actor = cx.this().clone();
$crate::Ret::some_to_actor(actor, move |_, cx, m: StopCause| {
if matches!(m, StopCause::Lost | StopCause::Failed(_)) {
cx.fail_string(message);
}
})
}};
($cx:expr, $error:expr) => {{
$crate::COVERAGE!(ret_failthru_2);
let error = $error;
let cx: &mut $crate::Cx<'_, _> = $cx;
let actor = cx.this().clone();
$crate::Ret::some_to_actor(actor, move |_, cx, m: StopCause| {
if matches!(m, StopCause::Lost | StopCause::Failed(_)) {
cx.fail(error)
}
})
}};
}
#[macro_export]
macro_rules! fail {
($cx:expr, $msg:literal) => {{
$crate::COVERAGE!(fail_0);
$cx.fail_str($msg);
}};
($cx:expr, $fmt:literal $(, $arg:expr)*) => {{
$crate::COVERAGE!(fail_1);
$cx.fail_string(format!($fmt $(, $arg)*));
}};
($cx:expr, $error:expr) => {{
$crate::COVERAGE!(fail_2);
$cx.fail($error);
}};
}
#[macro_export]
macro_rules! stop {
($cx:expr) => {{
$crate::COVERAGE!(stop_0);
$cx.stop();
}};
}
#[macro_export]
macro_rules! kill {
($actor:expr, $msg:literal) => {{
$crate::COVERAGE!(kill_0);
let actor: $crate::ActorOwn<_> = $actor.owned();
$actor.defer(move |s| actor.kill_str(s, $msg));
}};
($actor:expr, $fmt:literal $(, $arg:expr)*) => {{
$crate::COVERAGE!(kill_1);
let actor: $crate::ActorOwn<_> = $actor.owned();
let msg = format!($fmt $(, $arg)*);
$actor.defer(move |s| actor.kill_string(s, msg));
}};
($actor:expr, $error:expr) => {{
$crate::COVERAGE!(kill_2);
let actor: $crate::ActorOwn<_> = $actor.owned();
let error = $error;
$actor.defer(move |s| actor.kill(s, error));
}};
}