[html5] r2043 - [] (0) Add a startConversation() method that wraps new MessageChannel and postMe [...]

whatwg at whatwg.org whatwg at whatwg.org
Mon Aug 11 00:34:02 PDT 2008


Author: ianh
Date: 2008-08-11 00:34:01 -0700 (Mon, 11 Aug 2008)
New Revision: 2043

Modified:
   index
   source
Log:
[] (0) Add a startConversation() method that wraps new MessageChannel and postMessage() in a less expensive one-step operation. (credit: ab)

Modified: index
===================================================================
--- index	2008-08-11 05:38:14 UTC (rev 2042)
+++ index	2008-08-11 07:34:01 UTC (rev 2043)
@@ -44009,6 +44009,7 @@
   readonly attribute boolean <a href="#active0" title=dom-MessagePort-active>active</a>;
   boolean <a href="#postmessage2" title=dom-MessagePort-postMessage>postMessage</a>(in DOMString message);
   boolean <a href="#postmessage2" title=dom-MessagePort-postMessage>postMessage</a>(in DOMString message, in <a href="#messageport0">MessagePort</a> messagePort);
+  <a href="#messageport0">MessagePort</a> <a href="#startconversation" title=dom-MessagePort-startConversation>startConversation</a>(in DOMString message);
   void <a href="#start6" title=dom-MessagePort-start>start</a>();
   void <a href="#close3" title=dom-MessagePort-close>close</a>();
 
@@ -44179,6 +44180,75 @@
 
   <hr>
 
+  <p>The <dfn id=startconversation
+   title=dom-MessagePort-startConversation><code>startConversation(<var
+   title="">message</var>)</code></dfn> method is a convenience method that
+   simplifies create a new <code><a
+   href="#messagechannel">MessageChannel</a></code> and invoking <code
+   title=dom-MessagePort-postMessage><a
+   href="#postmessage2">postMessage()</a></code> with one of the new ports.
+   When invoked on a port <var title="">source port</var>, it must run the
+   following steps:
+
+  <ol>
+   <li>
+    <p>Let <var title="">message</var> be the method's first argument.
+
+   <li>
+    <p>If the <var title="">source port</var> is not entangled with another
+     port, then return null and abort these steps.
+   </li>
+   <!--
+   we don't raise an exception because this can happen moment's
+   notice, but we return false so that the caller can check whether
+   the port was active at time of calling without a race
+   condition. -->
+
+   <li>
+    <p>Let <var title="">target port</var> be the port with which <var
+     title="">source port</var> is entangled.
+
+   <li>
+    <p>Create an event that uses the <code><a
+     href="#messageevent">MessageEvent</a></code> interface, with the name
+     <code title=event-message><a href="#message2">message</a></code>, which
+     does not bubble, is cancelable, and has no default action.
+
+   <li>
+    <p>Let the <code title=dom-MessageEvent-data><a
+     href="#data4">data</a></code> attribute of the event have the value of
+     <var title="">message</var>, the method's first argument.
+
+   <li>
+    <p><a href="#create">Create a new <code>MessagePort</code> object</a>
+     owned by the <a href="#script2">script execution context</a>, and let
+     <var title="">port1</var> be that object.
+
+   <li>
+    <p><a href="#create">Create a new <code>MessagePort</code> object</a>
+     owned by the owner of the <var title="">target port</var>, and let <var
+     title="">port2</var> be that object.
+
+   <li>
+    <p><a href="#entangle">Entangle</a> the <var title="">port1</var> and
+     <var title="">port2</var> objects.
+
+   <li>
+    <p>Let the <code title=dom-MessageEvent-messagePort><a
+     href="#messageport">messagePort</a></code> attribute of the event be
+     <var title="">port2</var>.
+
+   <li>
+    <p>Return <var title="">port1</var> from the method, but continue with
+     these steps.
+
+   <li>
+    <p>Add the event to the <a href="#port-message">port message queue</a> of
+     <var title="">target port</var>.
+  </ol>
+
+  <hr>
+
   <p>The <dfn id=start6
    title=dom-MessagePort-start><code>start()</code></dfn> method must open
    its port's <a href="#port-message">port message queue</a>, if it is not

Modified: source
===================================================================
--- source	2008-08-11 05:38:14 UTC (rev 2042)
+++ source	2008-08-11 07:34:01 UTC (rev 2043)
@@ -41470,6 +41470,7 @@
   readonly attribute boolean <span title="dom-MessagePort-active">active</span>;
   boolean <span title="dom-MessagePort-postMessage">postMessage</span>(in DOMString message);
   boolean <span title="dom-MessagePort-postMessage">postMessage</span>(in DOMString message, in <span>MessagePort</span> messagePort);
+  <span>MessagePort</span> <span title="dom-MessagePort-startConversation">startConversation</span>(in DOMString message);
   void <span title="dom-MessagePort-start">start</span>();
   void <span title="dom-MessagePort-close">close</span>();
 
@@ -41636,6 +41637,64 @@
 
   <hr>
 
+  <p>The <dfn
+  title="dom-MessagePort-startConversation"><code>startConversation(<var
+  title="">message</var>)</code></dfn> method is a convenience method
+  that simplifies create a new <code>MessageChannel</code> and
+  invoking <code
+  title="dom-MessagePort-postMessage">postMessage()</code> with one of
+  the new ports. When invoked on a port <var title="">source
+  port</var>, it must run the following steps:</p>
+
+  <ol>
+
+   <li><p>Let <var title="">message</var> be the method's first
+   argument.</p></li>
+
+   <li><p>If the <var title="">source port</var> is not entangled with
+   another port, then return null and abort these steps.</p></li> <!--
+   we don't raise an exception because this can happen moment's
+   notice, but we return false so that the caller can check whether
+   the port was active at time of calling without a race
+   condition. -->
+
+   <li><p>Let <var title="">target port</var> be the port with which
+   <var title="">source port</var> is entangled.</p></li>
+
+   <li><p>Create an event that uses the <code>MessageEvent</code>
+   interface, with the name <code
+   title="event-message">message</code>, which does not bubble, is
+   cancelable, and has no default action.</p></li>
+
+   <li><p>Let the <code title="dom-MessageEvent-data">data</code>
+   attribute of the event have the value of <var
+   title="">message</var>, the method's first argument.</p></li>
+
+   <li><p><span>Create a new <code>MessagePort</code> object</span>
+   owned by the <span>script execution context</span>, and let <var
+   title="">port1</var> be that object.</p></li>
+
+   <li><p><span>Create a new <code>MessagePort</code> object</span>
+   owned by the owner of the <var title="">target port</var>, and let
+   <var title="">port2</var> be that object.</p></li>
+
+   <li><p><span>Entangle</span> the <var title="">port1</var> and <var
+   title="">port2</var> objects.</p></li>
+ 
+   <li><p>Let the <code
+   title="dom-MessageEvent-messagePort">messagePort</code> attribute
+   of the event be <var title="">port2</var>.</p></li>
+
+   <li><p>Return <var title="">port1</var> from the method, but
+   continue with these steps.</p></li>
+
+   <li><p>Add the event to the <span>port message queue</span> of <var
+   title="">target port</var>.</p></li>
+
+  </ol>
+
+  <hr>
+
   <p>The <dfn title="dom-MessagePort-start"><code>start()</code></dfn>
   method must open its port's <span>port message queue</span>, if it
   is not already open.</p>




More information about the Commit-Watchers mailing list