| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7e38821 commit a159a2c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,35 +14,31 @@ class NextTickQueue { | |||
| 14 | 14 | constructor() { | |
| 15 | 15 | this.head = null; | |
| 16 | 16 | this.tail = null; | |
| 17 | - this.length = 0; | ||
| 18 | 17 | } | |
| 19 | 18 | ||
| 20 | 19 | push(v) { | |
| 21 | 20 | const entry = { data: v, next: null }; | |
| 22 | - if (this.length > 0) | ||
| 21 | + if (this.tail !== null) | ||
| 23 | 22 | this.tail.next = entry; | |
| 24 | 23 | else | |
| 25 | 24 | this.head = entry; | |
| 26 | 25 | this.tail = entry; | |
| 27 | - ++this.length; | ||
| 28 | 26 | } | |
| 29 | 27 | ||
| 30 | 28 | shift() { | |
| 31 | - if (this.length === 0) | ||
| 29 | + if (this.head === null) | ||
| 32 | 30 | return; | |
| 33 | 31 | const ret = this.head.data; | |
| 34 | - if (this.length === 1) | ||
| 32 | + if (this.head === this.tail) | ||
| 35 | 33 | this.head = this.tail = null; | |
| 36 | 34 | else | |
| 37 | 35 | this.head = this.head.next; | |
| 38 | - --this.length; | ||
| 39 | 36 | return ret; | |
| 40 | 37 | } | |
| 41 | 38 | ||
| 42 | 39 | clear() { | |
| 43 | 40 | this.head = null; | |
| 44 | 41 | this.tail = null; | |
| 45 | - this.length = 0; | ||
| 46 | 42 | } | |
| 47 | 43 | } | |
| 48 | 44 | ||
@@ -90,7 +86,7 @@ function setupNextTick() { | |||
| 90 | 86 | nextTickQueue.clear(); | |
| 91 | 87 | tickInfo[kLength] = 0; | |
| 92 | 88 | } else { | |
| 93 | - tickInfo[kLength] = nextTickQueue.length; | ||
| 89 | + tickInfo[kLength] -= tickInfo[kIndex]; | ||
| 94 | 90 | } | |
| 95 | 91 | } | |
| 96 | 92 | tickInfo[kIndex] = 0; | |
@@ -124,8 +120,6 @@ function setupNextTick() { | |||
| 124 | 120 | } | |
| 125 | 121 | } | |
| 126 | 122 | ||
| 127 | - // Run callbacks that have no domain. | ||
| 128 | - // Using domains will cause this to be overridden. | ||
| 129 | 123 | function _tickCallback() { | |
| 130 | 124 | do { | |
| 131 | 125 | while (tickInfo[kIndex] < tickInfo[kLength]) { | |
@@ -137,7 +131,8 @@ function setupNextTick() { | |||
| 137 | 131 | // CHECK(Number.isSafeInteger(tock[trigger_async_id_symbol])) | |
| 138 | 132 | // CHECK(tock[trigger_async_id_symbol] > 0) | |
| 139 | 133 | ||
| 140 | - emitBefore(tock[async_id_symbol], tock[trigger_async_id_symbol]); | ||
| 134 | + const asyncId = tock[async_id_symbol]; | ||
| 135 | + emitBefore(asyncId, tock[trigger_async_id_symbol]); | ||
| 141 | 136 | // emitDestroy() places the async_id_symbol into an asynchronous queue | |
| 142 | 137 | // that calls the destroy callback in the future. It's called before | |
| 143 | 138 | // calling tock.callback so destroy will be called even if the callback | |
@@ -148,15 +143,15 @@ function setupNextTick() { | |||
| 148 | 143 | // any async hooks are enabled during the callback's execution then | |
| 149 | 144 | // this tock's after hook will be called, but not its destroy hook. | |
| 150 | 145 | if (async_hook_fields[kDestroy] > 0) | |
| 151 | - emitDestroy(tock[async_id_symbol]); | ||
| 146 | + emitDestroy(asyncId); | ||
| 152 | 147 | ||
| 153 | 148 | const callback = tock.callback; | |
| 154 | 149 | if (tock.args === undefined) | |
| 155 | 150 | callback(); | |
| 156 | 151 | else | |
| 157 | 152 | Reflect.apply(callback, undefined, tock.args); | |
| 158 | 153 | ||
| 159 | - emitAfter(tock[async_id_symbol]); | ||
| 154 | + emitAfter(asyncId); | ||
| 160 | 155 | ||
| 161 | 156 | if (kMaxCallbacksPerLoop < tickInfo[kIndex]) | |
| 162 | 157 | tickDone(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments