Skip to content

Commit

Permalink
Fix and format
Browse files Browse the repository at this point in the history
  • Loading branch information
vertexclique committed Oct 24, 2019
1 parent 58e0c72 commit 5f358ef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
16 changes: 10 additions & 6 deletions lightproc/examples/proc_panic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::future::Future;
use std::sync::Arc;

use std::thread;

use crossbeam::channel::{unbounded, Sender};
Expand All @@ -9,8 +9,6 @@ use lightproc::prelude::*;

use lightproc::recoverable_handle::RecoverableHandle;

use std::sync::atomic::AtomicUsize;

fn spawn_on_thread<F, R>(future: F) -> RecoverableHandle<R>
where
F: Future<Output = R> + Send + 'static,
Expand Down Expand Up @@ -38,9 +36,15 @@ where
schedule,
ProcStack::default()
.with_pid(1)
.with_before_start(|| { println!("Before start"); })
.with_after_complete(|| { println!("After complete"); })
.with_after_panic(|| { println!("After panic"); })
.with_before_start(|| {
println!("Before start");
})
.with_after_complete(|| {
println!("After complete");
})
.with_after_panic(|| {
println!("After panic");
}),
);

proc.schedule();
Expand Down
9 changes: 6 additions & 3 deletions lightproc/examples/proc_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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 @@ -29,8 +28,12 @@ where
schedule,
ProcStack::default()
.with_pid(1)
.with_before_start(|| { println!("Before start"); })
.with_after_complete(|| { println!("After complete"); })
.with_before_start(|| {
println!("Before start");
})
.with_after_complete(|| {
println!("After complete");
}),
);

proc.schedule();
Expand Down
6 changes: 3 additions & 3 deletions lightproc/src/proc_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ impl ProcStack {

pub fn with_before_start<T>(mut self, callback: T) -> Self
where
T: Fn() + Send + Sync + 'static
T: Fn() + Send + Sync + 'static,
{
self.before_start = Some(Arc::new(callback));
self
}

pub fn with_after_complete<T>(mut self, callback: T) -> Self
where
T: Fn() + Send + Sync + 'static
T: Fn() + Send + Sync + 'static,
{
self.after_complete = Some(Arc::new(callback));
self
}

pub fn with_after_panic<T>(mut self, callback: T) -> Self
where
T: Fn() + Send + Sync + 'static
T: Fn() + Send + Sync + 'static,
{
self.after_panic = Some(Arc::new(callback));
self
Expand Down

0 comments on commit 5f358ef

Please sign in to comment.