mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
ensure clean shutdown of all threads running JS
This commit is contained in:
parent
0b61cfc3ae
commit
44ebca72da
25 changed files with 565 additions and 232 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue