summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/src/thread_nextTick.js
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2015-04-04 01:00:59 -0700
committeryo mama <pepper@scannerjammer.com>2015-04-04 01:00:59 -0700
commitc7c22e3db1c826bcfb2bc66651ec480aae0d4ae0 (patch)
tree8546df448afef40d3814d2581f4dacff7cebb87f /node_modules/webworker-threads/src/thread_nextTick.js
Diffstat (limited to 'node_modules/webworker-threads/src/thread_nextTick.js')
-rw-r--r--node_modules/webworker-threads/src/thread_nextTick.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/src/thread_nextTick.js b/node_modules/webworker-threads/src/thread_nextTick.js
new file mode 100644
index 0000000..e8cf3c0
--- /dev/null
+++ b/node_modules/webworker-threads/src/thread_nextTick.js
@@ -0,0 +1,29 @@
+function ThreadNextTick(){
+ function nextTick(cb){
+ thread._ntq.push(cb);
+ return this;
+ }
+ function dispatchNextTicks(l, p, err, _ntq){
+ var e;
+ if (l = (_ntq = thread._ntq).length) {
+ p = err = 0;
+ try {
+ for (;;) {
+ _ntq[p]();
+ if (!(++p < l)) {
+ break;
+ }
+ }
+ } catch (e$) {
+ e = e$;
+ thread._ntq = _ntq.slice(++p);
+ throw e;
+ }
+ return (thread._ntq = _ntq.slice(p)).length;
+ }
+ return 0;
+ }
+ thread._ntq = [];
+ thread.nextTick = nextTick;
+ return dispatchNextTicks;
+}