mirror of
https://github.com/servo/servo.git
synced 2025-06-13 02:44:29 +00:00
Make RunnableWrapper store an Option<Arc<AtomicBool>>
This makes WorkerGlobalScope::get_runnable_wrapper not panic anymore when the worker is a ServiceWorkerGlobalScope.
This commit is contained in:
parent
991801488c
commit
ca8c6fb072
3 changed files with 7 additions and 5 deletions
|
@ -170,7 +170,7 @@ impl InProgressLoad {
|
|||
|
||||
/// Encapsulated state required to create cancellable runnables from non-script threads.
|
||||
pub struct RunnableWrapper {
|
||||
pub cancelled: Arc<AtomicBool>,
|
||||
pub cancelled: Option<Arc<AtomicBool>>,
|
||||
}
|
||||
|
||||
impl RunnableWrapper {
|
||||
|
@ -184,7 +184,7 @@ impl RunnableWrapper {
|
|||
|
||||
/// A runnable that can be discarded by toggling a shared flag.
|
||||
pub struct CancellableRunnable<T: Runnable + Send> {
|
||||
cancelled: Arc<AtomicBool>,
|
||||
cancelled: Option<Arc<AtomicBool>>,
|
||||
inner: Box<T>,
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,9 @@ impl<T: Runnable + Send> Runnable for CancellableRunnable<T> {
|
|||
fn name(&self) -> &'static str { self.inner.name() }
|
||||
|
||||
fn is_cancelled(&self) -> bool {
|
||||
self.cancelled.load(Ordering::SeqCst)
|
||||
self.cancelled.as_ref()
|
||||
.map(|cancelled| cancelled.load(Ordering::SeqCst))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn main_thread_handler(self: Box<CancellableRunnable<T>>, script_thread: &ScriptThread) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue