diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2014-12-29 22:56:15 +0100 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2014-12-30 08:20:50 +0100 |
commit | b9a6366f96e14e396452da443b64a10ee480fabf (patch) | |
tree | 0b23538cd302d3bd42c6784a74b0c8df882a74dc /src | |
parent | 29bf3385add5ee9306452fe605984838ecfaa1a5 (diff) | |
download | glutin-b9a6366f96e14e396452da443b64a10ee480fabf.tar.gz glutin-b9a6366f96e14e396452da443b64a10ee480fabf.zip |
Update for changes in Send/Sync traits
Diffstat (limited to 'src')
-rw-r--r-- | src/android/mod.rs | 8 | ||||
-rw-r--r-- | src/osx/headless.rs | 3 | ||||
-rw-r--r-- | src/osx/mod.rs | 5 | ||||
-rw-r--r-- | src/win32/init.rs | 8 | ||||
-rw-r--r-- | src/win32/mod.rs | 11 | ||||
-rw-r--r-- | src/x11/headless.rs | 3 | ||||
-rw-r--r-- | src/x11/window/mod.rs | 3 |
7 files changed, 39 insertions, 2 deletions
diff --git a/src/android/mod.rs b/src/android/mod.rs index 7279f99..111d4b4 100644 --- a/src/android/mod.rs +++ b/src/android/mod.rs @@ -60,6 +60,11 @@ impl HeadlessContext { } } +#[cfg(feature = "headless")] +unsafe impl Send for HeadlessContext {} +#[cfg(feature = "headless")] +unsafe impl Sync for HeadlessContext {} + impl Window { pub fn new(builder: WindowBuilder) -> Result<Window, CreationError> { use std::{mem, ptr}; @@ -275,6 +280,9 @@ impl Window { } } +unsafe impl Send for Window {} +unsafe impl Sync for Window {} + #[cfg(feature = "window")] #[deriving(Clone)] pub struct WindowProxy; diff --git a/src/osx/headless.rs b/src/osx/headless.rs index bbe3d9f..1332cf3 100644 --- a/src/osx/headless.rs +++ b/src/osx/headless.rs @@ -99,6 +99,9 @@ impl HeadlessContext { } } +unsafe impl Send for HeadlessContext {} +unsafe impl Sync for HeadlessContext {} + impl Drop for HeadlessContext { fn drop(&mut self) { unsafe { diff --git a/src/osx/mod.rs b/src/osx/mod.rs index 7df6603..92ef641 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -73,6 +73,11 @@ impl Window { } #[cfg(feature = "window")] +unsafe impl Send for Window {} +#[cfg(feature = "window")] +unsafe impl Sync for Window {} + +#[cfg(feature = "window")] #[deriving(Clone)] pub struct WindowProxy; diff --git a/src/win32/init.rs b/src/win32/init.rs index 3cdf8d5..7b236b0 100644 --- a/src/win32/init.rs +++ b/src/win32/init.rs @@ -18,11 +18,15 @@ use winapi; /// receive an event for another window. thread_local!(static WINDOW: Rc<RefCell<Option<(winapi::HWND, Sender<Event>)>>> = Rc::new(RefCell::new(None))); +/// Work-around the fact that HGLRC doesn't implement Send +pub struct ContextHack(pub winapi::HGLRC); +unsafe impl Send for ContextHack {} + pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: String, builder_monitor: Option<super::MonitorID>, builder_gl_version: Option<(uint, uint)>, builder_debug: bool, builder_vsync: bool, builder_hidden: bool, - builder_sharelists: Option<winapi::HGLRC>, builder_multisampling: Option<u16>) + builder_sharelists: Option<ContextHack>, builder_multisampling: Option<u16>) -> Result<Window, CreationError> { use std::mem; @@ -38,6 +42,8 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin // so we create a new thread dedicated to this window. // This is the only safe method. Using `nosend` wouldn't work for non-native runtime. ::std::thread::Thread::spawn(move || { + let builder_sharelists = builder_sharelists.map(|s| s.0); + // registering the window class let class_name = { let class_name: Vec<u16> = "Window Class".utf16_units().chain(Some(0).into_iter()) diff --git a/src/win32/mod.rs b/src/win32/mod.rs index dba08e5..a5f0547 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -51,6 +51,11 @@ impl HeadlessContext { } } +#[cfg(feature = "headless")] +unsafe impl Send for HeadlessContext {} +#[cfg(feature = "headless")] +unsafe impl Sync for HeadlessContext {} + /// The Win32 implementation of the main `Window` object. pub struct Window { /// Main handle for the window. @@ -75,6 +80,9 @@ pub struct Window { is_closed: AtomicBool, } +unsafe impl Send for Window {} +unsafe impl Sync for Window {} + #[cfg(feature = "window")] impl Window { /// See the docs in the crate root file. @@ -82,7 +90,8 @@ impl Window { let WindowBuilder { dimensions, title, monitor, gl_version, gl_debug, vsync, visible, sharing, multisampling } = builder; init::new_window(dimensions, title, monitor, gl_version, gl_debug, vsync, - !visible, sharing.map(|w| w.window.context), multisampling) + !visible, sharing.map(|w| init::ContextHack(w.window.context)), + multisampling) } } diff --git a/src/x11/headless.rs b/src/x11/headless.rs index 95f5233..d6f1023 100644 --- a/src/x11/headless.rs +++ b/src/x11/headless.rs @@ -62,3 +62,6 @@ impl Drop for HeadlessContext { unsafe { ffi::OSMesaDestroyContext(self.context) } } } + +unsafe impl Send for HeadlessContext {} +unsafe impl Sync for HeadlessContext {} diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs index 422b5b6..0a8c3d5 100644 --- a/src/x11/window/mod.rs +++ b/src/x11/window/mod.rs @@ -34,6 +34,9 @@ struct XWindow { im: ffi::XIM, } +unsafe impl Send for Window {} +unsafe impl Sync for Window {} + impl Drop for XWindow { fn drop(&mut self) { unsafe { |