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

[whatwg] WebWorkers vs. Threads

From: Aaron Boodman <aa@google.com>
Date: Thu, 14 Aug 2008 00:34:31 -0700
Message-ID: <278fd46c0808140034n643affcck64617776c389f361@mail.gmail.com>
On Thu, Aug 14, 2008 at 12:23 AM, Kristof Zelechovski
<giecrilj at stegny.2a.pl> wrote:
> Sorry, I do not get it.  Where does the value of (la) make it into
> (e.message)?

Sorry, I forgot a line:

> // main.js
> var la = 0; // what is with this variable name?
> var worker = createWorker("worker.js");
> worker.port.addEventListener("message", function(e) {
>  la = parseInt(e.message);
>  alert(la);
> }, false);

worker.port.sendMessage(la);

> // worker.js
> workerGlobalScope.port.addEventListener("message", function(e) {
>  workerGlobalScope.port.sendMessage(
> someLongRunningFunction(parseInt(e.message)));
> }, false);

Code not tested, so there still might be mistakes. But I hope the
point gets across.

- a
Received on Thursday, 14 August 2008 00:34:31 UTC

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