bare-worker 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -2
- package/lib/message-port.js +3 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,7 +24,7 @@ module.exports = exports = class Worker extends MessagePort {
|
|
|
24
24
|
this._exitCode = 0
|
|
25
25
|
this._terminating = null
|
|
26
26
|
|
|
27
|
-
this.
|
|
27
|
+
this.start()
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
terminate() {
|
|
@@ -48,7 +48,9 @@ module.exports = exports = class Worker extends MessagePort {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
_onclose() {
|
|
52
|
+
super._onclose()
|
|
53
|
+
|
|
52
54
|
this._thread.join()
|
|
53
55
|
|
|
54
56
|
if (this._terminating !== null) this._terminating.resolve(this._exitCode)
|
package/lib/message-port.js
CHANGED
|
@@ -190,6 +190,7 @@ module.exports = exports = class MessagePort extends EventEmitter {
|
|
|
190
190
|
MessagePort._ports.delete(this)
|
|
191
191
|
|
|
192
192
|
this._state |= constants.state.CLOSED
|
|
193
|
+
|
|
193
194
|
this.emit('close')
|
|
194
195
|
}
|
|
195
196
|
|
|
@@ -199,12 +200,14 @@ module.exports = exports = class MessagePort extends EventEmitter {
|
|
|
199
200
|
|
|
200
201
|
_ononline() {
|
|
201
202
|
this._state |= constants.state.ONLINE
|
|
203
|
+
|
|
202
204
|
this.emit('online')
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
_onerror(err) {
|
|
206
208
|
this._exitCode = 1
|
|
207
209
|
this._terminate()
|
|
210
|
+
|
|
208
211
|
this.emit('error', err)
|
|
209
212
|
}
|
|
210
213
|
|