Skip to content

Commit

Permalink
After complete callback done
Browse files Browse the repository at this point in the history
  • Loading branch information
vertexclique committed Oct 20, 2019
1 parent 1b0f39b commit 3838dec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lightproc/examples/proc_run.rs
Expand Up @@ -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<F, R>(fut: F) -> ProcHandle<R>
where
Expand All @@ -26,7 +27,15 @@ fn spawn_on_thread<F, R>(fut: F) -> ProcHandle<R>
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();
Expand Down
4 changes: 4 additions & 0 deletions lightproc/src/raw_proc.rs
Expand Up @@ -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;
Expand Down

0 comments on commit 3838dec

Please sign in to comment.