From abdf9078ef13154374f75fa0bb9c28a15c9286bd Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Sun, 3 Apr 2016 22:29:40 +0200 Subject: [PATCH] make RustBox type Send, but still not Sync The RustBox type is not thread safe, in the sense that multiple threads may never alter the mutable state of a shared RustBox at the same time, so it should not be marked Sync. However, a RustBox type *can* safely be sent between threads so it *should* be marked Send. This commit makes it possible to wrap a RustBox struct inside a Mutex type, so that it can still be used when the programmer decides to do the syncronization theirself. --- src/rustbox.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rustbox.rs b/src/rustbox.rs index 464d207..9cad75a 100644 --- a/src/rustbox.rs +++ b/src/rustbox.rs @@ -5,6 +5,7 @@ extern crate termbox_sys as termbox; pub use self::style::{Style, RB_BOLD, RB_UNDERLINE, RB_REVERSE, RB_NORMAL}; +use std::cell::UnsafeCell; use std::error::Error; use std::fmt; use std::io; @@ -221,7 +222,7 @@ pub struct RustBox { // top-down order. Otherwise it will not properly protect the above fields. _running: running::RunningGuard, // Termbox is not thread safe. See #39. - _phantom: PhantomData<*mut ()>, + _phantom: PhantomData>, } #[derive(Clone, Copy,Debug)]