mirror of https://gitee.com/openkylin/nodejs.git
16 lines
425 B
JavaScript
16 lines
425 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
const { MessageChannel } = require('worker_threads');
|
|
|
|
// Make sure that closing a message port while receiving messages on it does
|
|
// not stop messages that are already in the queue from being emitted.
|
|
|
|
const { port1, port2 } = new MessageChannel();
|
|
|
|
port1.on('message', common.mustCall(() => {
|
|
port1.close();
|
|
}, 2));
|
|
port2.postMessage('foo');
|
|
port2.postMessage('bar');
|