diff options
Diffstat (limited to 'components/layout/flow_ref.rs')
-rw-r--r-- | components/layout/flow_ref.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/components/layout/flow_ref.rs b/components/layout/flow_ref.rs index 67f306d4508..605a7e4ede5 100644 --- a/components/layout/flow_ref.rs +++ b/components/layout/flow_ref.rs @@ -10,15 +10,19 @@ use flow::Flow; use flow; use std::mem; +use std::ops::{Deref, DerefMut}; use std::ptr; use std::raw; -use std::sync::atomic::SeqCst; +use std::sync::atomic::Ordering; #[unsafe_no_drop_flag] pub struct FlowRef { object: raw::TraitObject, } +unsafe impl Send for FlowRef {} +unsafe impl Sync for FlowRef {} + impl FlowRef { pub fn new(mut flow: Box<Flow>) -> FlowRef { unsafe { @@ -33,7 +37,8 @@ impl FlowRef { } } -impl<'a> Deref<Flow + 'a> for FlowRef { +impl<'a> Deref for FlowRef { + type Target = Flow + 'a; fn deref(&self) -> &(Flow + 'a) { unsafe { mem::transmute_copy::<raw::TraitObject, &(Flow + 'a)>(&self.object) @@ -41,7 +46,7 @@ impl<'a> Deref<Flow + 'a> for FlowRef { } } -impl<'a> DerefMut<Flow + 'a> for FlowRef { +impl DerefMut for FlowRef { fn deref_mut<'a>(&mut self) -> &mut (Flow + 'a) { unsafe { mem::transmute_copy::<raw::TraitObject, &mut (Flow + 'a)>(&self.object) @@ -55,7 +60,7 @@ impl Drop for FlowRef { if self.object.vtable.is_null() { return } - if flow::base(&**self).ref_count().fetch_sub(1, SeqCst) > 1 { + if flow::base(&**self).ref_count().fetch_sub(1, Ordering::SeqCst) > 1 { return } let flow_ref: FlowRef = mem::replace(self, FlowRef { @@ -75,7 +80,7 @@ impl Drop for FlowRef { impl Clone for FlowRef { fn clone(&self) -> FlowRef { unsafe { - drop(flow::base(self.deref()).ref_count().fetch_add(1, SeqCst)); + drop(flow::base(&**self).ref_count().fetch_add(1, Ordering::SeqCst)); FlowRef { object: raw::TraitObject { vtable: self.object.vtable, |