W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2008

[whatwg] Combining the DedicatedWorker and SharedWorker interfaces

From: Alexey Proskuryakov <ap@webkit.org>
Date: Wed, 5 Nov 2008 17:56:42 +0300
Message-ID: <F663827F-B945-4254-B37E-48419938D9C4@webkit.org>

Nov 5, 2008, ? 1:11 AM, Jonas Sicking ???????(?):

> main.js:
> w = new Worker('worker.js');
> p = w.connect();
> p.postMessage(17);
> p.onmessage = function(e) {
>  answer = e.data;
> }


I prefer to think of it as:

window.onload = function() {
     var worker = new Worker('encrypt.js');
     var workerPort = worker.connect();
     workerPort.onmessage = processWorkerReply;
}

function spawnEncryptData(id, data) {
    workerPort.postMessage("encrypt " + id + " " + data);
}

Aside from one time setup (which usually needs to be performed in  
advance), the "simple case" looks no different, but there is no  
confusion about which port to use.

- WBR, Alexey Proskuryakov
Received on Wednesday, 5 November 2008 06:56:42 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:07 UTC