From bb315f25f84c93b69d99d41b2c68185639c30e83 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Wed, 24 Dec 2014 17:40:40 +0100 Subject: Implement RaceBox for StdinReader --- src/libstd/sys/common/helper_thread.rs | 9 ++++++++- src/libstd/sys/windows/timer.rs | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs index b0137bdad06..a629f035b07 100644 --- a/src/libstd/sys/common/helper_thread.rs +++ b/src/libstd/sys/common/helper_thread.rs @@ -63,6 +63,11 @@ unsafe impl Send for Helper { } unsafe impl Sync for Helper { } +struct RaceBox(helper_signal::signal); + +unsafe impl Send for RaceBox {} +unsafe impl Sync for RaceBox {} + impl Helper { /// Lazily boots a helper thread, becoming a no-op if the helper has already /// been spawned. @@ -85,9 +90,11 @@ impl Helper { let (receive, send) = helper_signal::new(); *self.signal.get() = send as uint; + let receive = RaceBox(receive); + let t = f(); Thread::spawn(move |:| { - helper(receive, rx, t); + helper(receive.0, rx, t); let _g = self.lock.lock(); *self.shutdown.get() = true; self.cond.notify_one() diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs index 7e4dd768aa9..874838950cd 100644 --- a/src/libstd/sys/windows/timer.rs +++ b/src/libstd/sys/windows/timer.rs @@ -48,6 +48,9 @@ pub enum Req { RemoveTimer(libc::HANDLE, Sender<()>), } +unsafe impl Send for Req {} + + fn helper(input: libc::HANDLE, messages: Receiver, _: ()) { let mut objs = vec![input]; let mut chans = vec![]; -- cgit 1.4.1-3-g733a5