[whatwg] localStorage + worker processes

On Sat, Mar 21, 2009 at 12:48 AM, Jonas Sicking <jonas at sicking.cc> wrote:
> What we could do, is to have an API like
>
> getLocalStorage(callback);
>
> This function returns immediately, but will then call the callback
> function as soon as the localStorage becomes available and the lock
> been acquired. This would always happen asynchronously off the event
> loop, which means that once the callback returns the lock is released
> again.

Funny, a few of us from Chromium were discussing a similar solution privately.

Actually, I don't believe that it is required that the callback run
asynchronously. All the callback is used for is establishing the lock
lifetime explicitly, and we assume that this will usually make the
lock lifetime short. So we can block while we wait for it to become
available. This is just like the behavior today without workers.

> This new API I believe is good enough to be used both from workers and
> window contexts.

We could maintain backward compatibility by not making it required on
normal web pages, because our assumption has been that web pages won't
hold the lock for long periods of time (because they wouldn't want to
block the UI either).

- a

Received on Saturday, 21 March 2009 09:38:35 UTC