diff options
author | Gregory Terzian <gterzian@users.noreply.github.com> | 2020-06-24 15:07:48 +0800 |
---|---|---|
committer | Gregory Terzian <gterzian@users.noreply.github.com> | 2020-06-30 13:22:38 +0800 |
commit | 44ebca72da45575df4e5970e25920c46c14aa0cb (patch) | |
tree | 88a9ed7d5529b9b83425d7b7cdd9b86f18ec12c2 /components/script/task.rs | |
parent | 0b61cfc3ae803ac0f9deef937f890f83b24c9a35 (diff) | |
download | servo-44ebca72da45575df4e5970e25920c46c14aa0cb.tar.gz servo-44ebca72da45575df4e5970e25920c46c14aa0cb.zip |
ensure clean shutdown of all threads running JS
Diffstat (limited to 'components/script/task.rs')
-rw-r--r-- | components/script/task.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/components/script/task.rs b/components/script/task.rs index 27600fdf8d7..b3200e23afe 100644 --- a/components/script/task.rs +++ b/components/script/task.rs @@ -69,7 +69,7 @@ impl fmt::Debug for dyn TaskBox { /// Encapsulated state required to create cancellable tasks from non-script threads. #[derive(Clone)] pub struct TaskCanceller { - pub cancelled: Option<Arc<AtomicBool>>, + pub cancelled: Arc<AtomicBool>, } impl TaskCanceller { @@ -88,7 +88,7 @@ impl TaskCanceller { /// A task that can be cancelled by toggling a shared flag. pub struct CancellableTask<T: TaskOnce> { - cancelled: Option<Arc<AtomicBool>>, + cancelled: Arc<AtomicBool>, inner: T, } @@ -97,9 +97,7 @@ where T: TaskOnce, { fn is_cancelled(&self) -> bool { - self.cancelled - .as_ref() - .map_or(false, |cancelled| cancelled.load(Ordering::SeqCst)) + self.cancelled.load(Ordering::SeqCst) } } |