diff --git a/lightproc/examples/proc_run.rs b/lightproc/examples/proc_run.rs index ad1e2382..62ddd2d5 100644 --- a/lightproc/examples/proc_run.rs +++ b/lightproc/examples/proc_run.rs @@ -7,6 +7,7 @@ use std::thread; use crossbeam::channel; use futures::executor; use lightproc::prelude::*; +use std::sync::atomic::AtomicUsize; fn spawn_on_thread(fut: F) -> ProcHandle where @@ -26,7 +27,15 @@ fn spawn_on_thread(fut: F) -> ProcHandle let (proc, handle) = LightProc::build( future, schedule, - ProcStack::default() + ProcStack { + pid: AtomicUsize::new(1), + after_complete: Some(Arc::new(|| { + println!("After complete"); + })), + after_start: Some(Arc::new(|| { + println!("After start"); + })) + } ); proc.schedule(); diff --git a/lightproc/src/raw_proc.rs b/lightproc/src/raw_proc.rs index df0e8507..2a2f3dc0 100644 --- a/lightproc/src/raw_proc.rs +++ b/lightproc/src/raw_proc.rs @@ -438,6 +438,10 @@ where (*raw.pdata).notify(); } + if let Some(after_complete_cb) = &(*raw.stack).after_complete { + (*after_complete_cb)(); + } + // Drop the task reference. Self::decrement(ptr); break;