Commit b2b310fe authored by Ralf's avatar Ralf
Browse files

cargo fmt

parent e76cfc7c
......@@ -10,4 +10,3 @@ pub enum Event {
Buzz,
UserCommand,
}
......@@ -18,25 +18,24 @@ struct ThreadState {
}
pub trait SpawnWakeable<'a> {
fn spawn_wakeable<F>(&self, f: F) where
F: FnOnce(WakeableThread) + Send + 'a;
fn spawn_wakeable<F>(&self, f: F) where F: FnOnce(WakeableThread) + Send + 'a;
}
impl<'a> SpawnWakeable<'a> for Scope<'a> {
fn spawn_wakeable<F>(&self, f: F) where
F: FnOnce(WakeableThread) + Send + 'a
fn spawn_wakeable<F>(&self, f: F)
where F: FnOnce(WakeableThread) + Send + 'a
{
let state = Arc::new(ThreadState {
mutex: Mutex::new(ShouldThreadRun::Yes),
cond: Condvar::new(),
});
let thread = WakeableThread { state: state.clone() };
self.spawn(move || f(thread) );
self.spawn(move || f(thread));
// Now defer the action that we want to wake up this thread.
// This will be executed *before* the join deferred by spawn.
self.defer(move || {
// We panic if the lock is poisened, which only happens if someone paniced
let mut should_run = state.mutex.lock().unwrap();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment