- From: Jonas Sicking <jonas@sicking.cc>
- Date: Thu, 6 Jan 2011 16:44:04 -0800
- To: Keean Schupke <keean@fry-it.com>
- Cc: Joćo Eiras <joao.eiras@gmail.com>, public-webapps WG <public-webapps@w3.org>
2011/1/6 Keean Schupke <keean@fry-it.com>: > Applying this to JavaScript (ignoring local storage and just implementing an > STM) would come up with something like: > 1) Objects from one thread should not be visible to another. Global variable > "test" defined in the UI or any worker thread should no be in scope in any > other worker-thread. > 2) shared objects could be accessed only though the "atomic" method > (implemented natively). > atomic(function(shared) { > shared.x += 1; > shared.y -= 2; > }); > Here, the callback is the transaction, and "shared" is the shared > namespace... Thats all you need for a basic implementation. The clever stuff > is all hidden from the user. > We could implement "retry" by returning true... the guard could just be a > boolean function too: > atomic(function(shared) { > if (queueSize > 0) { > // remove item from queue and use it > return false; // no retry > } else { > return true; // retry > } > }); > Thats pretty much the entire user visible API that would be needed. Of > course the implementation behind the scenes is more complex. This looks basically like what I proposed with "getBetterStoreage" renamed to "atomic". But I'm guessing that it's also intended that atomic is synchronous whereas getBetterStoreage was asynchronous. I think that would be fine in workers, but it'd have many of the same complications as the storage mutex if implemented for the main thread. / Jonas
Received on Friday, 7 January 2011 00:48:42 UTC