stop() and stop_facet(facet_id) now return unit

This commit is contained in:
Tony Garnock-Jones 2021-10-07 16:59:34 +02:00
parent 7b6a2dab76
commit 0d7ac7441f
7 changed files with 17 additions and 15 deletions

View File

@ -41,7 +41,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
t.dataflow(enclose!((current_value) move |t| { t.dataflow(enclose!((current_value) move |t| {
if *t.get(&current_value) == 1000000 { if *t.get(&current_value) == 1000000 {
t.stop()?; t.stop();
} }
Ok(()) Ok(())
}))?; }))?;
@ -62,7 +62,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
*count = *count - 1; *count = *count - 1;
if *count == 0 { if *count == 0 {
tracing::info!("box state retracted"); tracing::info!("box state retracted");
t.stop()?; t.stop();
} }
Ok(()) Ok(())
}))) })))

View File

@ -481,7 +481,7 @@ fn run(
} }
} }
for facet_id in to_stop.into_iter() { for facet_id in to_stop.into_iter() {
t.stop_facet(facet_id)?; t.stop_facet(facet_id);
} }
Ok(()) Ok(())
}).unwrap() }).unwrap()
@ -507,7 +507,7 @@ fn run(
let _ = facet.activate(Account::new(syndicate::name!("termination")), |t| { let _ = facet.activate(Account::new(syndicate::name!("termination")), |t| {
tracing::trace!("linked thread terminating associated facet"); tracing::trace!("linked thread terminating associated facet");
t.stop() Ok(t.stop())
}); });
tracing::trace!("linked thread done"); tracing::trace!("linked thread done");

View File

@ -341,7 +341,7 @@ fn run(
let completed = *t.get(&completed_processes); let completed = *t.get(&completed_processes);
tracing::debug!(total_configs = ?total, completed_processes = ?completed); tracing::debug!(total_configs = ?total, completed_processes = ?completed);
if total > 0 && total == completed { if total > 0 && total == completed {
t.stop()?; t.stop();
} }
Ok(()) Ok(())
}))?; }))?;

View File

@ -33,7 +33,7 @@ struct ShutdownEntity;
impl Entity<AnyValue> for ShutdownEntity { impl Entity<AnyValue> for ShutdownEntity {
fn message(&mut self, t: &mut Activation, _m: AnyValue) -> ActorResult { fn message(&mut self, t: &mut Activation, _m: AnyValue) -> ActorResult {
t.stop() Ok(t.stop())
} }
} }
@ -93,7 +93,7 @@ pub fn bench_pub(c: &mut Criterion) {
let ds = Cap::new(&t.create(Dataspace::new())); let ds = Cap::new(&t.create(Dataspace::new()));
let shutdown = entity(()) let shutdown = entity(())
.on_asserted(|_, _, _| Ok(Some(Box::new(|_, t| t.stop())))) .on_asserted(|_, _, _| Ok(Some(Box::new(|_, t| Ok(t.stop())))))
.create_cap(t); .create_cap(t);
ds.assert(t, language(), &Observe { ds.assert(t, language(), &Observe {

View File

@ -68,7 +68,7 @@ pub fn bench_ring(c: &mut Criterion) {
tracing::info!(iters = self.iters, tracing::info!(iters = self.iters,
actors_created = ACTORS_CREATED.load(Ordering::SeqCst), actors_created = ACTORS_CREATED.load(Ordering::SeqCst),
messages_sent = MESSAGES_SENT.load(Ordering::SeqCst)); messages_sent = MESSAGES_SENT.load(Ordering::SeqCst));
t.stop()?; t.stop();
self.tx.send(self.start.elapsed() / ACTOR_COUNT).unwrap() self.tx.send(self.start.elapsed() / ACTOR_COUNT).unwrap()
} }
Ok(()) Ok(())

View File

@ -926,7 +926,7 @@ impl<'activation> Activation<'activation> {
f.linked_tasks.remove(&task_id); f.linked_tasks.remove(&task_id);
} }
if let LinkedTaskTermination::Normal = result { if let LinkedTaskTermination::Normal = result {
t.stop()?; t.stop();
} }
Ok(()) Ok(())
}); });
@ -1080,15 +1080,17 @@ impl<'activation> Activation<'activation> {
/// Arranges for the [`Facet`] named by `facet_id` to be stopped cleanly when `self` /// Arranges for the [`Facet`] named by `facet_id` to be stopped cleanly when `self`
/// commits. /// commits.
/// ///
/// Equivalent to `self.stop_facet_and_continue(facet_id, None)`. /// Equivalent to `self.stop_facet_and_continue(facet_id, None)`, except that the lack of a
pub fn stop_facet(&mut self, facet_id: FacetId) -> ActorResult { /// continuation means that there's no need for this method to return `ActorResult`.
pub fn stop_facet(&mut self, facet_id: FacetId) {
self.stop_facet_and_continue::<Action>(facet_id, None) self.stop_facet_and_continue::<Action>(facet_id, None)
.expect("Non-failing stop_facet_and_continue")
} }
/// Arranges for the active facet to be stopped cleanly when `self` commits. /// Arranges for the active facet to be stopped cleanly when `self` commits.
/// ///
/// Equivalent to `self.stop_facet(self.facet.facet_id)`. /// Equivalent to `self.stop_facet(self.facet.facet_id)`.
pub fn stop(&mut self) -> ActorResult { pub fn stop(&mut self) {
self.stop_facet(self.facet.facet_id) self.stop_facet(self.facet.facet_id)
} }
@ -1098,7 +1100,7 @@ impl<'activation> Activation<'activation> {
tracing::trace!("Checking inertness of facet {} from facet {}", facet_id, t.facet.facet_id); tracing::trace!("Checking inertness of facet {} from facet {}", facet_id, t.facet.facet_id);
if t.state.facet_exists_and_is_inert(facet_id) { if t.state.facet_exists_and_is_inert(facet_id) {
tracing::trace!(" - facet {} is inert, stopping it", facet_id); tracing::trace!(" - facet {} is inert, stopping it", facet_id);
t.stop_facet(facet_id)?; t.stop_facet(facet_id);
} else { } else {
tracing::trace!(" - facet {} is not inert", facet_id); tracing::trace!(" - facet {} is not inert", facet_id);
} }
@ -1986,7 +1988,7 @@ where
impl<M> Entity<M> for StopOnRetract { impl<M> Entity<M> for StopOnRetract {
fn retract(&mut self, t: &mut Activation, _h: Handle) -> ActorResult { fn retract(&mut self, t: &mut Activation, _h: Handle) -> ActorResult {
t.stop() Ok(t.stop())
} }
} }

View File

@ -118,7 +118,7 @@ where
let _ = t.prevent_inert_check(); let _ = t.prevent_inert_check();
assertion_handler(state, t, a) assertion_handler(state, t, a)
})?; })?;
Ok(Some(Box::new(move |_state, t| t.stop_facet(facet_id)))) Ok(Some(Box::new(move |_state, t| Ok(t.stop_facet(facet_id)))))
})) }))
} }