Re: Workers

Thanks, Ian.
But some moments are still not clear.

Ian Hickson wrote:
> On Fri, 18 Jul 2008, Andrew Fedoniouk wrote:
...
 >> (why it is "window" btw?)
 >
 > Because it is implemented by the Window object. For legacy reasons the
 > global object is generally called 'window'. To allow easy porting
 > of code to workers, we have kept the same names.


So the thread will have that 'window'/'self' object in global
namespace, correct?

What about window.document, window.history, etc. then?

> 
> 
>> 1) It appears that such VMs have access to the same DOM. How 
>> synchronization of access to the DOM happens then?
> 
> There is no shared state. There is also currently no separate DOM access 
> of any kind (not even independent DOM trees or DOMs from XHR), since 
> implementations don't want to make their DOM implementations thread safe.
> 

It appears as there is some shared state - the DOM per se.
Almost any object in DOM and Event modules has references
to window or document. MessageEvent for example has field 'source'.

> 
>> 2) It appears 
>> (http://www.whatwg.org/specs/web-workers/current-work/#processing) as 
>> all VMs are capable to share other objects like opened databases. What 
>> about synchronization of method calls?
> 
> The database APIs are transactional.
> 

Sorry but that is not clear.
Terms "DB transactional" and "multithread DB" are orthogonal. There are 
a lot of DB engines that support transactions but do not support 
multithreading. SQLite is such an engine for example.

> 
>> 3) It is not clear how Workers receive DOM events and which ones by the 
>> way?
> 
> Well they can fire whatever DOM events they want on themselves. For 
> communication through the channel messaging system the events fired by 
> message ports are the ones used to communicate; see:
> 
>    http://www.whatwg.org/specs/web-apps/current-work/#channel
> 

What exactly is the DOM event?
This one: http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-Event
?

What about such attribute as event.target? It is DOM object usually. Or 
event.source? If yes then what prevents Worker to store it and to 
manipulate DOM or window from second thread?


-- 
Andrew Fedoniouk.

http://terrainformatica.com

Received on Saturday, 19 July 2008 02:41:07 UTC