diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-03 14:10:55 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-03 14:10:55 -0800 |
commit | 6ec190d3940cc2c115563ac924dc9a18325bf8c2 (patch) | |
tree | 59895b9a082e20d072510ad72f0a72b3c08999b2 /src/library_browser.js | |
parent | aca0e4d8b27f797d8bf3338e2032aa758d3fde98 (diff) | |
parent | 168ec74a34743e3b2dc295ada9ccecbc689cf441 (diff) |
Merge branch 'allow_multiple_worker_responses' of github.com:virusdave/emscripten into incoming
Conflicts:
AUTHORS
Diffstat (limited to 'src/library_browser.js')
-rw-r--r-- | src/library_browser.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index 47b3b2f9..03da394e 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -1,7 +1,6 @@ //"use strict"; // Utilities for browser environments - mergeInto(LibraryManager.library, { $Browser__deps: ['$PATH'], $Browser__postset: 'Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };\n' + // exports @@ -1011,8 +1010,11 @@ mergeInto(LibraryManager.library, { var callbackId = msg.data['callbackId']; var callbackInfo = info.callbacks[callbackId]; if (!callbackInfo) return; // no callback or callback removed meanwhile - info.awaited--; - info.callbacks[callbackId] = null; // TODO: reuse callbackIds, compress this + // Don't trash our callback state if we expect additional calls. + if (msg.data['finalResponse']) { + info.awaited--; + info.callbacks[callbackId] = null; // TODO: reuse callbackIds, compress this + } var data = msg.data['data']; if (data) { if (!data.byteLength) data = new Uint8Array(data); @@ -1059,12 +1061,23 @@ mergeInto(LibraryManager.library, { }); }, + emscripten_worker_respond_provisionally: function(data, size) { + if (!inWorkerCall) throw 'not in worker call!'; + if (workerResponded) throw 'already responded with final response!'; + postMessage({ + 'callbackId': workerCallbackId, + 'finalResponse': false, + 'data': data ? new Uint8Array({{{ makeHEAPView('U8', 'data', 'data + size') }}}) : 0 // XXX copy to a new typed array as a workaround for chrome bug 169705 + }); + }, + emscripten_worker_respond: function(data, size) { if (!inWorkerCall) throw 'not in worker call!'; - if (workerResponded) throw 'already responded!'; + if (workerResponded) throw 'already responded with final response!'; workerResponded = true; postMessage({ 'callbackId': workerCallbackId, + 'finalResponse': true, 'data': data ? new Uint8Array({{{ makeHEAPView('U8', 'data', 'data + size') }}}) : 0 // XXX copy to a new typed array as a workaround for chrome bug 169705 }); }, |