sharedarraybuffer

Javascript Workers - why is the worker message treated so lately and can I do something against it?

可紊 提交于 2020-06-28 09:16:17
问题 I have a Worker that shares a SharedArrayBuffer with the "main thread". To work correctly, I have to make sure that the worker has access to the SAB before the main thread accesses to it. (EDIT: The code creating the worker has to be in a seperate function (EDIT2: which returns an array pointing to the SAB).) (Maybe, already this is not possible, you'll tell me). The initial code looks like this: function init() { var code = `onmessage = function(event) { console.log('starting'); var buffer

Does `postMessage` or yielding to the event loop or similar sync shared memory?

送分小仙女□ 提交于 2019-12-09 15:01:17
问题 I don't see anything in the JavaScript spec, the proposed DOM spec extensions related to SharedArrayBuffer , or the current WHAT-WG HTML spec to suggest that shared memory will be synchronized/updated across threads when one thread posts a message to another and the other processes the message. ( After the one has already sent the shared memory to the other.) However, I'm also unable to verify experimentally that it doesn't happen (in my tests, I don't see stale values). Is there some such