W3C home > Mailing lists > Public > public-html-diffs@w3.org > March 2010

workers; hixie: Add more shared worker examples. (whatwg r4865)

From: poot <cvsmail@w3.org>
Date: Thu, 25 Mar 2010 09:53:14 +0900 (JST)
To: public-html-diffs@w3.org
Message-Id: <20100325005315.3F8AB2BC58@toro.w3.mag.keio.ac.jp>
workers; hixie: Add more shared worker examples. (whatwg r4865)

http://dev.w3.org/cvsweb/html5/workers/Overview.html?r1=1.237&r2=1.238&f=h
http://html5.org/tools/web-apps-tracker?from=4864&to=4865

===================================================================
RCS file: /sources/public/html5/workers/Overview.html,v
retrieving revision 1.237
retrieving revision 1.238
diff -u -d -r1.237 -r1.238
--- Overview.html	24 Mar 2010 22:26:35 -0000	1.237
+++ Overview.html	25 Mar 2010 00:52:59 -0000	1.238
@@ -193,7 +193,7 @@
    <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
    <h1>Web Workers</h1>
 
-   <h2 class="no-num no-toc" id="editor-s-draft-24-march-2010">Editor's Draft 24 March 2010</h2>
+   <h2 class="no-num no-toc" id="editor-s-draft-25-march-2010">Editor's Draft 25 March 2010</h2>
    <dl><dt>Latest Published Version:</dt>
     <dd><a href="http://www.w3.org/TR/workers/">http://www.w3.org/TR/workers/</a></dd>
     <dt>Latest Editor's Draft:</dt>
@@ -254,7 +254,7 @@
   Working Group</a> is the W3C working group responsible for this
   specification's progress along the W3C Recommendation track.
 
-  This specification is the 24 March 2010 Editor's Draft.
+  This specification is the 25 March 2010 Editor's Draft.
   </p><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- relationship to other work (required) --><p>This specification is also being produced by the <a href="http://www.whatwg.org/">WHATWG</a>. The two specifications are
   identical from the table of contents onwards.</p><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- context and rationale (required) --><p>This specification is intended to specify a part of the Web
   platform closely related to HTML5. It is defined in a separate
@@ -278,9 +278,10 @@
      <li><a href="#a-background-number-crunching-worker"><span class="secno">1.2.1 </span>A background number-crunching worker</a></li>
      <li><a href="#a-worker-for-updating-a-client-side-database"><span class="secno">1.2.2 </span>A worker for updating a client-side database</a></li>
      <li><a href="#worker-used-for-background-i-o"><span class="secno">1.2.3 </span>Worker used for background I/O</a></li>
-     <li><a href="#shared-workers"><span class="secno">1.2.4 </span>Shared workers</a></li>
-     <li><a href="#delegation"><span class="secno">1.2.5 </span>Delegation</a></li>
-     <li><a href="#providing-libraries"><span class="secno">1.2.6 </span>Providing libraries</a></ol></ol></li>
+     <li><a href="#shared-workers-introduction"><span class="secno">1.2.4 </span>Shared workers introduction</a></li>
+     <li><a href="#shared-state-using-a-shared-worker"><span class="secno">1.2.5 </span>Shared state using a shared worker</a></li>
+     <li><a href="#delegation"><span class="secno">1.2.6 </span>Delegation</a></li>
+     <li><a href="#providing-libraries"><span class="secno">1.2.7 </span>Providing libraries</a></ol></ol></li>
  <li><a href="#conformance-requirements"><span class="secno">2 </span>Conformance requirements</a>
   <ol>
    <li><a href="#dependencies"><span class="secno">2.1 </span>Dependencies</a></ol></li>
@@ -461,7 +462,20 @@
 };</pre><p>The search query worker is as follows:<pre>importScripts('io.js');
 onmessage = function (event) {
   postMessage(get('search.cgi?' + event.data));
-};</pre><p><a href="http://www.whatwg.org/demos/workers/stocks/page.html">View this example online</a>.<h4 id="shared-workers"><span class="secno">1.2.4 </span>Shared workers</h4><p><i>This section is non-normative.</i><p>In this example, multiple windows (viewers) can be opened that
+};</pre><p><a href="http://www.whatwg.org/demos/workers/stocks/page.html">View this example online</a>.<h4 id="shared-workers-introduction"><span class="secno">1.2.4 </span>Shared workers introduction</h4><p><i>This section is non-normative.</i><p>This section introduces shared workers using a Hello World
+  example. Shared workers use slightly different APIs, since each
+  worker can have multiple connections.<p>This first example shows how you connect to a worker and how a
+  worker can send a message back to the page when it connects to
+  it. Received messages are displayed in a log.<p>Here is the HTML page:<pre>EXAMPLE workers/shared/001/test.html</pre><p>Here is the JavaScript worker:<pre>EXAMPLE workers/shared/001/test.js</pre><hr><p>This second example extends the first one by changing two things:
+  first, messages are received using <code title="">addEventListener()</code> instead of an <span title="event
+  handler IDL attributes">event handler IDL attribute</span>, and
+  second, a message is sent <em>to</em> the worker, causing the worker
+  to send another message in return. Received messages are again
+  displayed in a lot.<p>Here is the HTML page:<pre>EXAMPLE workers/shared/001/test.html</pre><p>Here is the JavaScript worker:<pre>EXAMPLE workers/shared/001/test.js</pre><hr><p>Finally, the example is extended to show how two pages can
+  connect to the same worker; in this case, the second page is merely
+  in an <code>iframe</code> on the first page, but the same principle
+  would apply to an entirely separate page in a separate
+  <span>top-level browsing context</span>.<p>Here is the outer HTML page:<pre>EXAMPLE workers/shared/003/test.html</pre><p>Here is the inner HTML page:<pre>EXAMPLE workers/shared/003/inner.html</pre><p>Here is the JavaScript worker:<pre>EXAMPLE workers/shared/003/test.js</pre><h4 id="shared-state-using-a-shared-worker"><span class="secno">1.2.5 </span>Shared state using a shared worker</h4><p><i>This section is non-normative.</i><p>In this example, multiple windows (viewers) can be opened that
   are all viewing the same map. All the windows share the same map
   information, with a single worker coordinating all the viewers. Each
   viewer can move around independently, but if they set any data on
@@ -714,7 +728,7 @@
   "msg" message from one viewer naming another viewer, it sets up a
   direct connection between the two, so that the two viewers can
   communicate directly without the worker having to proxy all the
-  messages.<p><a href="http://www.whatwg.org/demos/workers/multiviewer/page.html">View this example online</a>.<h4 id="delegation"><span class="secno">1.2.5 </span>Delegation</h4><p><i>This section is non-normative.</i><p>With multicore CPUs becoming prevalent, one way to obtain better
+  messages.<p><a href="http://www.whatwg.org/demos/workers/multiviewer/page.html">View this example online</a>.<h4 id="delegation"><span class="secno">1.2.6 </span>Delegation</h4><p><i>This section is non-normative.</i><p>With multicore CPUs becoming prevalent, one way to obtain better
   performance is to split computationally expensive tasks amongst
   multiple workers. In this example, a computationally expensive task
   that is to be performed for every number from 1 to 10,000,000 is
@@ -777,7 +791,7 @@
   close();
 }</pre><p>They receive two numbers in two events, perform the computation
   for the range of numbers thus specified, and then report the result
-  back to the parent.<p><a href="http://www.whatwg.org/demos/workers/multicore/page.html">View this example online</a>.<h4 id="providing-libraries"><span class="secno">1.2.6 </span>Providing libraries</h4><p><i>This section is non-normative.</i><p>Suppose that a cryptography library is made available that
+  back to the parent.<p><a href="http://www.whatwg.org/demos/workers/multicore/page.html">View this example online</a>.<h4 id="providing-libraries"><span class="secno">1.2.7 </span>Providing libraries</h4><p><i>This section is non-normative.</i><p>Suppose that a cryptography library is made available that
   provides three tasks:<dl><dt>Generate a public/private key pair</dt>
 
    <dd>Takes a port, on which it will send two messages, first the
Received on Thursday, 25 March 2010 00:53:44 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 18 December 2010 06:14:18 GMT