[whatwg] Workers proposal

Michael Nordman michaeln at google.com
Wed Aug 20 19:10:56 PDT 2008


On Wed, Aug 20, 2008 at 5:36 PM, Ian Hickson <ian at hixie.ch> wrote:

>
> I've received feedback from a number of people requesting a rethink to the
> API for creating and communicating with workers.
>
> Here is a skeleton of a new proposal. It makes the following changes:
>
>  * Shared workers and dedicated workers get their own interfaces,
>   inheriting from a common base interface, both for the global scope
>   objects and for the objects returned when they are created.
>
>  * Shared workers get a port per connection. Dedicated workers don't get a
>   port, but they have a convenience method on the worker and on the
>   worker's global object that allows for easy creation of ports to send
>   threaded messages (direct replies).
>
>  * Uses constructors instead of factory methods to create workers.
>
>  * Removes 'onload' from the Worker objects.
>
>  * Renamed "onunload" to "onclose" throughout.
>
>  * Removes the "closing" boolean.
>
>  * Adds a way to kill a dedicated worker.
>
>
> OUTSIDE
>
> // (abstract, never instantiated)
> [NoInterfaceObject] interface Worker {
>  attribute EventListener onerror; // invoked if the worker fails to start
>  attribute EventListener onclose; // invoked if the worker closes
> };
>
> interface DedicatedWorker : Worker {
>  void close(); // kills the worker immediately, without cleanup


Is the shutdown sequence initiated by this method call different then the
shutdown sequence initiated by a call to self.close() from within the worker
itself?  The comment hints that it is... if so why?


>
>
>  // these all work the same as on MessagePorts:
>  attribute EventListener onmessage; // receives messages from the worker
>  boolean postMessage(in DOMString message);
>  boolean postMessage(in DOMString message, in MessagePort, port);
>  MessagePort startConversation(in DOMString message);
> };
>
> interface SharedWorker : Worker {
>  readonly attribute MessagePort port; // local end of channel to worker
> };
>
>
> INSIDE
>
> // (abstract, never instantiated)
> [NoInterfaceObject] interface WorkerGlobalScope {
>  void close();
>  attribute EventListener onclose;
>
>  readonly attribute WorkerGlobalScope self;
>  readonly attribute WorkerLocation location;
>  // also implements everything on WorkerUtils
> };
>
> [NoInterfaceObject] interface DedicatedWorkerGlobalScope :
> WorkerGlobalScope {
>  // these all work the same as on MessagePorts:
>  attribute EventListener onmessage; // receives messages from the owner
>  boolean postMessage(in DOMString message);
>  boolean postMessage(in DOMString message, in MessagePort, port);
>  MessagePort startConversation(in DOMString message);
> };
>
> [NoInterfaceObject] interface DedicatedWorkerGlobalScope :
> WorkerGlobalScope {
>  attribute EventListener onconnect; // called by createSharedWorker()
>  readonly attribute DOMString name;
> };
>
>
> CREATING WORKERS
>
> To created workes, use constructors:
>
>   var worker = new DedicatedWorker(url);
>   var service = new SharedWorker(name, url);
>

Is it possible for a worker (shared or dedicated) to reload itself?


>
>
> Comments?
>

How do workers and appCaches interact?


>
> --
> Ian Hickson               U+1047E                )\._.,--....,'``.    fL
> http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
> Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20080820/d5f4a2cd/attachment.htm>


More information about the whatwg mailing list