aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-10-26 11:45:21 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-10-26 11:45:21 -0700
commit3f855a246e873ca2c862e3747f530cd0544f2f25 (patch)
tree43ab90203593c76d6b5afad0b4cedf47cfc1c7aa /src/library_browser.js
parentff52d178360a0dd1d7bca018d5872d0aaebdfba6 (diff)
emscripten_get_worker_queue_size
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index 7c1d4320..d7aba76f 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -574,6 +574,7 @@ mergeInto(LibraryManager.library, {
var info = {
worker: new Worker(url),
callbacks: [],
+ awaited: 0,
buffer: 0,
bufferSize: 0
};
@@ -583,6 +584,7 @@ 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
var data = msg.data['data'];
if (data) {
@@ -619,6 +621,7 @@ mergeInto(LibraryManager.library, {
func: Runtime.getFuncWrapper(callback),
arg: arg
});
+ info.awaited++;
}
info.worker.postMessage({
'funcName': funcName,
@@ -635,6 +638,12 @@ mergeInto(LibraryManager.library, {
'callbackId': workerCallbackId,
'data': data ? {{{ makeHEAPView('U8', 'data', 'data + size') }}} : 0
});
+ },
+
+ emscripten_get_worker_queue_size: function(id) {
+ var info = Browser.workers[id];
+ if (!info) return -1;
+ return info.awaited;
}
});