diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-07-22 11:34:49 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-07-22 11:34:49 -0700 |
commit | 82ce326a9a9a1f4fa4291b05b57d2e4d7c487314 (patch) | |
tree | 1de76ade138ac176b7e7b18325c32292a190f441 | |
parent | 67ba7bdd0211f2fd472277d7eac1cad4be010a36 (diff) |
nudge progress a little with non-counted blockers
-rw-r--r-- | src/library_browser.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index 4d474217..f4b5164c 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -268,8 +268,18 @@ mergeInto(LibraryManager.library, { var start = Date.now(); var blocker = Browser.mainLoop.queue.shift(); blocker.func(); - console.log('main loop blocker "' + blocker.name + '" took ' + (Date.now() - start) + ' ms'); - if (Browser.mainLoop.remainingBlockers) Browser.mainLoop.remainingBlockers--; + if (Browser.mainLoop.remainingBlockers) { + var remaining = Browser.mainLoop.remainingBlockers; + var next = remaining%1 == 0 ? remaining-1 : Math.floor(remaining); + if (blocker.counted) { + Browser.mainLoop.remainingBlockers = next; + } else { + // not counted, but move the progress along a tiny bit + next = next + 0.5; // do not steal all the next one's progress + Browser.mainLoop.remainingBlockers = (8*remaining + next)/9; + } + } + console.log('main loop blocker "' + blocker.name + '" took ' + (Date.now() - start) + ' ms, left: ' + Browser.mainLoop.remainingBlockers); Browser.mainLoop.updateStatus(); setTimeout(wrapper, 0); return; @@ -315,15 +325,12 @@ mergeInto(LibraryManager.library, { }, _emscripten_push_main_loop_blocker: function(func, name) { - Browser.mainLoop.queue.push({ func: FUNCTION_TABLE[func], name: Pointer_stringify(name) }); + Browser.mainLoop.queue.push({ func: FUNCTION_TABLE[func], name: Pointer_stringify(name), counted: true }); Browser.mainLoop.updateStatus(); }, _emscripten_push_uncounted_main_loop_blocker: function(func, name) { - Browser.mainLoop.queue.push({ func: function() { - FUNCTION_TABLE[func](); - Browser.mainLoop.remainingBlockers++; // balance our regular reduction - }, name: Pointer_stringify(name) }); + Browser.mainLoop.queue.push({ func: FUNCTION_TABLE[func], name: Pointer_stringify(name), counted: false }); Browser.mainLoop.updateStatus(); }, |