Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[giow] (3) Make MessagePort objects synchronised until they are poste…
…d through another port.

Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=15063
Affected topics: DOM APIs

git-svn-id: http://svn.whatwg.org/webapps@7669 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jan 29, 2013
1 parent 4fa98d7 commit 15f253c
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 5 deletions.
31 changes: 29 additions & 2 deletions complete.html
Expand Up @@ -84684,7 +84684,26 @@ <h4 id=message-ports><span class=secno>10.5.3 </span>Message ports</h4>
queue</a> can be enabled or disabled, and is initially
disabled. Once enabled, a port can never be disabled again (though
messages in the queue can get moved to another queue or removed
altogether, which has much the same effect).</p>
altogether, which has much the same effect).
A <code><a href=#messageport>MessagePort</a></code> also has a <dfn id=has-been-shipped>has been shipped</dfn> flag. It must initially be
false.</p>

<p>Each <a href=#event-loop>event loop</a> has a <a href=#task-source>task source</a> called the <dfn id=unshipped-port-message-queue>unshipped port
message queue</dfn>. This is a virtual <a href=#task-source>task source</a>: it must act as if it contained
the <a href=#concept-task title=concept-task>tasks</a> of each <a href=#port-message-queue>port message queue</a> of each
<code><a href=#messageport>MessagePort</a></code> whose <a href=#has-been-shipped>has been shipped</a> flag is false, in the order in which
they were added to their respective <a href=#task-source>task source</a>. When a <a href=#concept-task title=concept-task>task</a> would be removed from the <a href=#unshipped-port-message-queue>unshipped port message
queue</a>, it must instead be removed from its <a href=#port-message-queue>port message queue</a>.</p>

<p>When a <code><a href=#messageport>MessagePort</a></code>'s <a href=#has-been-shipped>has been shipped</a> flag is false, its <a href=#port-message-queue>port
message queue</a> must be ignored for the purposes of the <a href=#event-loop>event loop</a>. (The
<a href=#unshipped-port-message-queue>unshipped port message queue</a> is used instead.)</p>

<p class=note>The <a href=#has-been-shipped>has been shipped</a> flag is set to true when a port, its twin, or
the object it was cloned from, is or has been <a href=#transfer-a-transferable-object title="transfer a transferable
object">transferred</a>. When a <code><a href=#messageport>MessagePort</a></code>'s <a href=#has-been-shipped>has been shipped</a> flag
is true, its <a href=#port-message-queue>port message queue</a> acts as a first-class <a href=#task-source>task source</a>,
unaffected to any <a href=#unshipped-port-message-queue>unshipped port message queue</a>.</p>

<p>When the user agent is to <dfn id=create-a-new-messageport-object>create a new
<code>MessagePort</code> object</dfn> owned by a <a href="#script's-global-object">script's
Expand Down Expand Up @@ -84717,10 +84736,15 @@ <h4 id=message-ports><span class=secno>10.5.3 </span>Message ports</h4>
a new <code><a href=#messageport>MessagePort</a></code> object. These steps must be run
atomically.</p>

<ol><li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a>
<ol><li><p>Set <var title="">original port</var>'s <a href=#has-been-shipped>has been shipped</a> flag to
true.</li>

<li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a>
owned by <var title="">owner</var>, and let <var title="">new
port</var> be that object.</li>

<li><p>Set <var title="">new port</var>'s <a href=#has-been-shipped>has been shipped</a> flag to true.</li>

<li><p>Move all the events in the <a href=#port-message-queue>port message queue</a>
of <var title="">original port</var> to the <a href=#port-message-queue>port message
queue</a> of <var title="">new port</var>, if any, leaving the
Expand All @@ -84735,6 +84759,9 @@ <h4 id=message-ports><span class=secno>10.5.3 </span>Message ports</h4>
<ol><li><p>Let the <var title="">remote port</var> be the port with
which the <var title="">original port</var> is entangled.</li>

<li><p>Set <var title="">remote port</var>'s <a href=#has-been-shipped>has been shipped</a> flag to
true.</li>

<li><p><a href=#entangle>Entangle</a> the <var title="">remote port</var>
and <var title="">new port</var> objects. The <var title="">original port</var> object will be disentangled by this
process.</li>
Expand Down
31 changes: 29 additions & 2 deletions index
Expand Up @@ -84684,7 +84684,26 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
queue</a> can be enabled or disabled, and is initially
disabled. Once enabled, a port can never be disabled again (though
messages in the queue can get moved to another queue or removed
altogether, which has much the same effect).</p>
altogether, which has much the same effect).
A <code><a href=#messageport>MessagePort</a></code> also has a <dfn id=has-been-shipped>has been shipped</dfn> flag. It must initially be
false.</p>

<p>Each <a href=#event-loop>event loop</a> has a <a href=#task-source>task source</a> called the <dfn id=unshipped-port-message-queue>unshipped port
message queue</dfn>. This is a virtual <a href=#task-source>task source</a>: it must act as if it contained
the <a href=#concept-task title=concept-task>tasks</a> of each <a href=#port-message-queue>port message queue</a> of each
<code><a href=#messageport>MessagePort</a></code> whose <a href=#has-been-shipped>has been shipped</a> flag is false, in the order in which
they were added to their respective <a href=#task-source>task source</a>. When a <a href=#concept-task title=concept-task>task</a> would be removed from the <a href=#unshipped-port-message-queue>unshipped port message
queue</a>, it must instead be removed from its <a href=#port-message-queue>port message queue</a>.</p>

<p>When a <code><a href=#messageport>MessagePort</a></code>'s <a href=#has-been-shipped>has been shipped</a> flag is false, its <a href=#port-message-queue>port
message queue</a> must be ignored for the purposes of the <a href=#event-loop>event loop</a>. (The
<a href=#unshipped-port-message-queue>unshipped port message queue</a> is used instead.)</p>

<p class=note>The <a href=#has-been-shipped>has been shipped</a> flag is set to true when a port, its twin, or
the object it was cloned from, is or has been <a href=#transfer-a-transferable-object title="transfer a transferable
object">transferred</a>. When a <code><a href=#messageport>MessagePort</a></code>'s <a href=#has-been-shipped>has been shipped</a> flag
is true, its <a href=#port-message-queue>port message queue</a> acts as a first-class <a href=#task-source>task source</a>,
unaffected to any <a href=#unshipped-port-message-queue>unshipped port message queue</a>.</p>

<p>When the user agent is to <dfn id=create-a-new-messageport-object>create a new
<code>MessagePort</code> object</dfn> owned by a <a href="#script's-global-object">script's
Expand Down Expand Up @@ -84717,10 +84736,15 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
a new <code><a href=#messageport>MessagePort</a></code> object. These steps must be run
atomically.</p>

<ol><li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a>
<ol><li><p>Set <var title="">original port</var>'s <a href=#has-been-shipped>has been shipped</a> flag to
true.</li>

<li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a>
owned by <var title="">owner</var>, and let <var title="">new
port</var> be that object.</li>

<li><p>Set <var title="">new port</var>'s <a href=#has-been-shipped>has been shipped</a> flag to true.</li>

<li><p>Move all the events in the <a href=#port-message-queue>port message queue</a>
of <var title="">original port</var> to the <a href=#port-message-queue>port message
queue</a> of <var title="">new port</var>, if any, leaving the
Expand All @@ -84735,6 +84759,9 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
<ol><li><p>Let the <var title="">remote port</var> be the port with
which the <var title="">original port</var> is entangled.</li>

<li><p>Set <var title="">remote port</var>'s <a href=#has-been-shipped>has been shipped</a> flag to
true.</li>

<li><p><a href=#entangle>Entangle</a> the <var title="">remote port</var>
and <var title="">new port</var> objects. The <var title="">original port</var> object will be disentangled by this
process.</li>
Expand Down
30 changes: 29 additions & 1 deletion source
Expand Up @@ -98334,7 +98334,27 @@ interface <dfn>MessageChannel</dfn> {
queue</span> can be enabled or disabled, and is initially
disabled. Once enabled, a port can never be disabled again (though
messages in the queue can get moved to another queue or removed
altogether, which has much the same effect).</p>
altogether, which has much the same effect).
A <code>MessagePort</code> also has a <dfn>has been shipped</dfn> flag. It must initially be
false.</p>

<p>Each <span>event loop</span> has a <span>task source</span> called the <dfn>unshipped port
message queue</dfn>. This is a virtual <span>task source</span>: it must act as if it contained
the <span title="concept-task">tasks</span> of each <span>port message queue</span> of each
<code>MessagePort</code> whose <span>has been shipped</span> flag is false, in the order in which
they were added to their respective <span>task source</span>. When a <span
title="concept-task">task</span> would be removed from the <span>unshipped port message
queue</span>, it must instead be removed from its <span>port message queue</span>.</p>

<p>When a <code>MessagePort</code>'s <span>has been shipped</span> flag is false, its <span>port
message queue</span> must be ignored for the purposes of the <span>event loop</span>. (The
<span>unshipped port message queue</span> is used instead.)</p>

<p class="note">The <span>has been shipped</span> flag is set to true when a port, its twin, or
the object it was cloned from, is or has been <span title="transfer a transferable
object">transferred</span>. When a <code>MessagePort</code>'s <span>has been shipped</span> flag
is true, its <span>port message queue</span> acts as a first-class <span>task source</span>,
unaffected to any <span>unshipped port message queue</span>.</p>

<p>When the user agent is to <dfn>create a new
<code>MessagePort</code> object</dfn> owned by a <span>script's
Expand Down Expand Up @@ -98375,10 +98395,15 @@ interface <dfn>MessageChannel</dfn> {

<ol>

<li><p>Set <var title="">original port</var>'s <span>has been shipped</span> flag to
true.</p></li>

<li><p><span>Create a new <code>MessagePort</code> object</span>
owned by <var title="">owner</var>, and let <var title="">new
port</var> be that object.</p></li>

<li><p>Set <var title="">new port</var>'s <span>has been shipped</span> flag to true.</p></li>

<li><p>Move all the events in the <span>port message queue</span>
of <var title="">original port</var> to the <span>port message
queue</span> of <var title="">new port</var>, if any, leaving the
Expand All @@ -98395,6 +98420,9 @@ interface <dfn>MessageChannel</dfn> {
<li><p>Let the <var title="">remote port</var> be the port with
which the <var title="">original port</var> is entangled.</p></li>

<li><p>Set <var title="">remote port</var>'s <span>has been shipped</span> flag to
true.</p></li>

<li><p><span>Entangle</span> the <var title="">remote port</var>
and <var title="">new port</var> objects. The <var
title="">original port</var> object will be disentangled by this
Expand Down

0 comments on commit 15f253c

Please sign in to comment.