diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-20 09:40:53 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-20 09:40:53 +0200 |
commit | f088b708c93e0a131cbfccf5c9b3797018f1c4ee (patch) | |
tree | d75727ac812624a7bee2b0bb827616af0540d99b /components/script/task.rs | |
parent | 8000efac75c96f87a5e242be84b246f98a1b61e5 (diff) | |
download | servo-f088b708c93e0a131cbfccf5c9b3797018f1c4ee.tar.gz servo-f088b708c93e0a131cbfccf5c9b3797018f1c4ee.zip |
Make Task require Send
Diffstat (limited to 'components/script/task.rs')
-rw-r--r-- | components/script/task.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/components/script/task.rs b/components/script/task.rs index 08f5c499aa6..dcefd31a162 100644 --- a/components/script/task.rs +++ b/components/script/task.rs @@ -15,7 +15,7 @@ macro_rules! task { struct $name<F>(F); impl<F> ::task::Task for $name<F> where - F: ::std::ops::FnOnce(), + F: ::std::ops::FnOnce() + Send, { fn name(&self) -> &'static str { stringify!($name) @@ -30,13 +30,13 @@ macro_rules! task { } /// A task that can be run. The name method is for profiling purposes. -pub trait Task { +pub trait Task: Send { #[allow(unsafe_code)] fn name(&self) -> &'static str { unsafe { intrinsics::type_name::<Self>() } } fn run(self: Box<Self>); } -impl fmt::Debug for Task + Send { +impl fmt::Debug for Task { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.debug_tuple(self.name()).field(&format_args!("...")).finish() } @@ -50,9 +50,9 @@ pub struct TaskCanceller { impl TaskCanceller { /// Returns a wrapped `task` that will be cancelled if the `TaskCanceller` /// says so. - pub fn wrap_task<T>(&self, task: Box<T>) -> Box<Task + Send> + pub fn wrap_task<T>(&self, task: Box<T>) -> Box<Task> where - T: Send + Task + 'static, + T: Task + 'static, { box CancellableTask { cancelled: self.cancelled.clone(), @@ -62,14 +62,14 @@ impl TaskCanceller { } /// A task that can be cancelled by toggling a shared flag. -pub struct CancellableTask<T: Send + Task> { +pub struct CancellableTask<T: Task> { cancelled: Option<Arc<AtomicBool>>, inner: Box<T>, } impl<T> CancellableTask<T> where - T: Send + Task, + T: Task, { fn is_cancelled(&self) -> bool { self.cancelled.as_ref().map_or(false, |cancelled| { @@ -80,7 +80,7 @@ where impl<T> Task for CancellableTask<T> where - T: Send + Task, + T: Task, { fn name(&self) -> &'static str { self.inner.name() |