From 46628fba05a548c1c2141d7c709b6e5d812f3114 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 17 Sep 2017 16:41:54 +0200 Subject: Move Task to its own module --- components/script/script_thread.rs | 59 -------------------------------------- 1 file changed, 59 deletions(-) (limited to 'components/script/script_thread.rs') diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 21989316864..56f47cfdbef 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -105,15 +105,12 @@ use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; use std::cell::Cell; use std::collections::{hash_map, HashMap, HashSet}; use std::default::Default; -use std::fmt; -use std::intrinsics; use std::ops::Deref; use std::option::Option; use std::ptr; use std::rc::Rc; use std::result::Result; use std::sync::Arc; -use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{Receiver, Select, Sender, channel}; use std::thread; use style::context::ReflowGoal; @@ -206,62 +203,6 @@ impl InProgressLoad { } } -/// Encapsulated state required to create cancellable tasks from non-script threads. -pub struct TaskCanceller { - pub cancelled: Option>, -} - -impl TaskCanceller { - pub fn wrap_task(&self, task: Box) -> Box - where - T: Send + Task + 'static, - { - box CancellableTask { - cancelled: self.cancelled.clone(), - inner: task, - } - } -} - -/// A task that can be discarded by toggling a shared flag. -pub struct CancellableTask { - cancelled: Option>, - inner: Box, -} - -impl CancellableTask -where - T: Send + Task, -{ - fn is_cancelled(&self) -> bool { - self.cancelled.as_ref().map_or(false, |cancelled| { - cancelled.load(Ordering::SeqCst) - }) - } -} - -impl Task for CancellableTask -where - T: Send + Task, -{ - fn run(self: Box) { - if !self.is_cancelled() { - self.inner.run() - } - } -} - -pub trait Task { - fn name(&self) -> &'static str { unsafe { intrinsics::type_name::() } } - fn run(self: Box); -} - -impl fmt::Debug for Task + Send { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_tuple(self.name()).field(&format_args!("...")).finish() - } -} - #[derive(Debug)] enum MixedMessage { FromConstellation(ConstellationControlMsg), -- cgit v1.2.3