W3C home > Mailing lists > Public > public-html-diffs@w3.org > February 2011

workers; hixie: Comment out an example that uses startConversation(), which isn't yet in the spec (it's commented out also). (whatwg r5838)

From: poot <cvsmail@w3.org>
Date: Mon, 07 Feb 2011 17:17:47 -0500
To: public-html-diffs@w3.org
Message-Id: <E1PmZP1-0005Rd-1N@jay.w3.org>
workers; hixie: Comment out an example that uses startConversation(),
which isn't yet in the spec (it's commented out also). (whatwg r5838)

http://dev.w3.org/cvsweb/html5/workers/Overview.html?r1=1.274&r2=1.275&f=h
http://html5.org/tools/web-apps-tracker?from=5837&to=5838

===================================================================
RCS file: /sources/public/html5/workers/Overview.html,v
retrieving revision 1.274
retrieving revision 1.275
diff -u -d -r1.274 -r1.275
--- Overview.html	7 Feb 2011 21:41:08 -0000	1.274
+++ Overview.html	7 Feb 2011 22:16:32 -0000	1.275
@@ -346,8 +346,7 @@
      <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-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="#delegation"><span class="secno">1.2.6 </span>Delegation</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>
@@ -922,8 +921,18 @@
   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.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>
+  back to the parent.<p><a href="http://www.whatwg.org/demos/workers/multicore/page.html">View this example online</a>.</p><!--(this uses startConversation, which is currently commented out)
+
+  <h4>Providing libraries</h4>
+
+  <!- -END dev-html- -><p><i>This section is non-normative.</i></p><!- -START dev-html- ->
+
+  <p>Suppose that a cryptography library is made available that
+  provides three tasks:</p>
+
+  <dl>
+
+   <dt>Generate a public/private key pair</dt>
 
    <dd>Takes a port, on which it will send two messages, first the
    public key and then the private key.</dd>
@@ -944,7 +953,11 @@
    channel as the plaintext. The user can close the port when it is
    done decrypting content.</dd>
 
-  </dl><p>The library itself is as follows:<pre>function handleMessage(e) {
+  </dl>
+
+  <p>The library itself is as follows:</p>
+
+  <pre>function handleMessage(e) {
   if (e.data == "genkeys")
     genkeys(e.ports[0]);
   else if (e.data == "encrypt")
@@ -1002,13 +1015,19 @@
 
 function _decrypt(k, s) {
   return s.substr(s.indexOf(' ')+1);
-}</pre><p>Note that the crypto functions here are just stubs and don't do
-  real cryptography.<p>This library could be used as follows:<pre>&lt;!DOCTYPE HTML&gt;
-&lt;html&gt;
- &lt;head&gt;
-  &lt;title&gt;Worker example: Crypto library&lt;/title&gt;
-  &lt;script&gt;
-   var crytoLib = new Worker('libcrypto-v1.js'); // or could use 'libcrypto-v2.js'
+}</pre>
+
+  <p>Note that the crypto functions here are just stubs and don't do
+  real cryptography.</p>
+
+  <p>This library could be used as follows:</p>
+
+  <pre>&lt;!DOCTYPE HTML>
+&lt;html>
+ &lt;head>
+  &lt;title>Worker example: Crypto library&lt;/title>
+  &lt;script>
+   var cryptoLib = new Worker('libcrypto-v1.js'); // or could use 'libcrypto-v2.js'
    function getKeys() {
      var state = 0;
      cryptoLib.startConversation("genkeys").onmessage = function (e) {
@@ -1037,22 +1056,26 @@
        port.close();
      };
    }
-  &lt;/script&gt;
-  &lt;style&gt;
+  &lt;/script>
+  &lt;style>
    textarea { display: block; }
-  &lt;/style&gt;
- &lt;/head&gt;
- &lt;body onload="getKeys()"&gt;
-  &lt;fieldset&gt;
-   &lt;legend&gt;Keys&lt;/legend&gt;
-   &lt;p&gt;&lt;label&gt;Public Key: &lt;textarea id="public"&gt;&lt;/textarea&gt;&lt;/label&gt;&lt;/p&gt;
-   &lt;p&gt;&lt;label&gt;Private Key: &lt;textarea id="private"&gt;&lt;/textarea&gt;&lt;/label&gt;&lt;/p&gt;
-  &lt;/fieldset&gt;
-  &lt;p&gt;&lt;label&gt;Input: &lt;textarea id="input"&gt;&lt;/textarea&gt;&lt;/label&gt;&lt;/p&gt;
-  &lt;p&gt;&lt;button onclick="enc()"&gt;Encrypt&lt;/button&gt; &lt;button onclick="dec()"&gt;Decrypt&lt;/button&gt;&lt;/p&gt;
- &lt;/body&gt;
-&lt;/html&gt;</pre><p>A later version of the API, though, might want to offload all the
-  crypto work onto subworkers. This could be done as follows:<pre>function handleMessage(e) {
+  &lt;/style>
+ &lt;/head>
+ &lt;body onload="getKeys()">
+  &lt;fieldset>
+   &lt;legend>Keys&lt;/legend>
+   &lt;p>&lt;label>Public Key: &lt;textarea id="public">&lt;/textarea>&lt;/label>&lt;/p>
+   &lt;p>&lt;label>Private Key: &lt;textarea id="private">&lt;/textarea>&lt;/label>&lt;/p>
+  &lt;/fieldset>
+  &lt;p>&lt;label>Input: &lt;textarea id="input">&lt;/textarea>&lt;/label>&lt;/p>
+  &lt;p>&lt;button onclick="enc()">Encrypt&lt;/button> &lt;button onclick="dec()">Decrypt&lt;/button>&lt;/p>
+ &lt;/body>
+&lt;/html></pre>
+
+  <p>A later version of the API, though, might want to offload all the
+  crypto work onto subworkers. This could be done as follows:</p>
+
+  <pre>function handleMessage(e) {
   if (e.data == "genkeys")
     genkeys(e.ports[0]);
   else if (e.data == "encrypt")
@@ -1087,7 +1110,13 @@
   onmessage = handleMessage;
 else // shared worker
   onconnect = function (e) { e.ports[0].onmessage = handleMessage };
-</pre><p>The little subworkers would then be as follows.<p>For generating key pairs:<pre>onmessage = function (e) {
+</pre>
+
+  <p>The little subworkers would then be as follows.</p>
+
+  <p>For generating key pairs:</p>
+
+  <pre>onmessage = function (e) {
   var k = _generateKeyPair();
   e.ports[0].postMessage(k[0]);
   e.ports[0].postMessage(k[1]);
@@ -1096,7 +1125,11 @@
 
 function _generateKeyPair() {
   return [Math.random(), Math.random()];
-}</pre><p>For encrypting:<pre>onmessage = function (e) {
+}</pre>
+
+  <p>For encrypting:</p>
+
+  <pre>onmessage = function (e) {
   var key = e.data;
   e.ports[0].onmessage = function (e) {
     var s = e.data;
@@ -1106,7 +1139,11 @@
 
 function _encrypt(k, s) {
   return 'encrypted-' + k + ' ' + s;
-}</pre><p>For decrypting:<pre>onmessage = function (e) {
+}</pre>
+
+  <p>For decrypting:</p>
+
+  <pre>onmessage = function (e) {
   var key = e.data;
   e.ports[0].onmessage = function (e) {
     var s = e.data;
@@ -1116,10 +1153,16 @@
 
 function _decrypt(k, s) {
   return s.substr(s.indexOf(' ')+1);
-}</pre><p>Notice how the users of the API don't have to even know that this
+}</pre>
+
+  <p>Notice how the users of the API don't have to even know that this
   is happening &mdash; the API hasn't changed; the library can
   delegate to subworkers without changing its API, even though it is
-  accepting data using message channels.<p><a href="http://www.whatwg.org/demos/workers/crypto/page.html">View this example online</a>.<h2 id="conformance-requirements"><span class="secno">2 </span>Conformance requirements</h2><p>All diagrams, examples, and notes in this specification are
+  accepting data using message channels.</p>
+
+  <p><a href="http://www.whatwg.org/demos/workers/crypto/page.html">View this example online</a>.</p>
+
+(end startConversation block) (beware nested comments)--><h2 id="conformance-requirements"><span class="secno">2 </span>Conformance requirements</h2><p>All diagrams, examples, and notes in this specification are
   non-normative, as are all sections explicitly marked non-normative.
   Everything else in this specification is normative.<p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL
   NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
Received on Monday, 7 February 2011 22:17:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 February 2011 22:17:52 GMT