[whatwg] Accessing cookies from workers

On Mon, Mar 9, 2009 at 11:46 AM, Giovanni Campagna
<scampa.giovanni at gmail.com> wrote:
> 2009/3/9 Jonas Sicking <jonas at sicking.cc>:
>> On Mon, Mar 9, 2009 at 11:26 AM, Giovanni Campagna
>> <scampa.giovanni at gmail.com> wrote:
>>> 2009/3/9 Jonas Sicking <jonas at sicking.cc>:
>>>> On Mon, Mar 9, 2009 at 11:01 AM, Giovanni Campagna
>>>>> This can be even worse: how would you syncronize the code in the
>>>>> callback with code right after the call? You don't have any of
>>>>> semaphores or mutexes in ES and I don't expect them to be added soon.
>>>>
>>>> I'm not sure I understand the problem you are describing. Could you
>>>> show an example using the APIs that exist in the spec today and with
>>>> an async cookie API added?
>>>
>>> var x = 7;
>>> function callback(cookies) {
>>> x = 5;
>>> }
>>> getAllCookies(callback);
>>> alert(x == 7);
>>
>> True. The callback can't happen in the middle of executing code.
>> Javascript uses a run-to-completion model.
>
> 1) what does that mean?

Sorry, i was unclear. The above program will always alert 'true'.

This happens because the callback doesn't fire until the current run
of javascript is finished executing. I.e. until the current event is
done executing.

> the code is executed in certain specific moments (when the thread is
> waiting on a native call)
> // doesn't seem very reliable, unless we specify what "native call" means

So something like this yes. We do need to specify what "native call"
means yes. The HTML5 spec does this as it is defining the runtime
environment for script execution.

> 2) where is that specified?
> I don't remember if the original Ecma262 has something about asyncronous calls

This area is in general woefully under specified by W3C. The HTML5
spec is the first attempt at specifying this.

> and most important
> 3) why it did actually happen in my code? (using an async XHR)

Not sure what you are saying here. Do you have example code.

/ Jonas

Received on Monday, 9 March 2009 16:55:42 UTC