Skip to content

Commit

Permalink
auto merge of #5360 : snf/servo/main_thread_runnable, r=jdm
Browse files Browse the repository at this point in the history
  • Loading branch information
bors-servo committed Mar 25, 2015
2 parents 644dc40 + e1f34b8 commit 7f587f6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/script/script_task.rs
Expand Up @@ -155,6 +155,10 @@ pub trait Runnable {
fn handler(self: Box<Self>);
}

pub trait MainThreadRunnable {
fn handler(self: Box<Self>, script_task: &ScriptTask);
}

/// Messages used to control script event loops, such as ScriptTask and
/// DedicatedWorkerGlobalScope.
pub enum ScriptMsg {
Expand All @@ -176,6 +180,8 @@ pub enum ScriptMsg {
DOMMessage(StructuredCloneData),
/// Generic message that encapsulates event handling.
RunnableMsg(Box<Runnable+Send>),
/// Generic message for running tasks in the ScriptTask
MainThreadRunnableMsg(Box<MainThreadRunnable+Send>),
/// A DOM object's last pinned reference was removed (dispatched to all tasks).
RefcountCleanup(TrustedReference),
/// The final network response for a page has arrived.
Expand Down Expand Up @@ -675,6 +681,8 @@ impl ScriptTask {
panic!("unexpected message"),
ScriptMsg::RunnableMsg(runnable) =>
runnable.handler(),
ScriptMsg::MainThreadRunnableMsg(runnable) =>
runnable.handler(self),
ScriptMsg::RefcountCleanup(addr) =>
LiveDOMReferences::cleanup(self.get_cx(), addr),
ScriptMsg::PageFetchComplete(id, subpage, response) =>
Expand Down

0 comments on commit 7f587f6

Please sign in to comment.