1 |
|
2 | function ThreadNextTick(){
|
3 | function nextTick(cb){
|
4 | thread._ntq.push(cb);
|
5 | return this;
|
6 | }
|
7 | function dispatchNextTicks(l, p, err, _ntq){
|
8 | var e;
|
9 | if (l = (_ntq = thread._ntq).length) {
|
10 | p = err = 0;
|
11 | try {
|
12 | for (;;) {
|
13 | _ntq[p]();
|
14 | if (!(++p < l)) {
|
15 | break;
|
16 | }
|
17 | }
|
18 | } catch (e$) {
|
19 | e = e$;
|
20 | thread._ntq = _ntq.slice(++p);
|
21 | throw e;
|
22 | }
|
23 | return (thread._ntq = _ntq.slice(p)).length;
|
24 | }
|
25 | return 0;
|
26 | }
|
27 | thread._ntq = [];
|
28 | thread.nextTick = nextTick;
|
29 | return dispatchNextTicks;
|
30 | }
|