n-api: make func argument of napi_create_threadsafe_function optional

PR-URL: https://github.com/nodejs/node/pull/27791
Refs: https://github.com/nodejs/node/issues/27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
This commit is contained in:
legendecas 2019-05-21 13:48:35 +08:00 committed by Rich Trott
parent ab3174ca08
commit 5705d7bf60
4 changed files with 68 additions and 11 deletions

View file

@ -102,6 +102,17 @@ new Promise(function testWithoutJSMarshaller(resolve) {
}))
.then((result) => assert.deepStrictEqual(result, expectedArray))
// Start the thread in blocking mode, and assert that all values are passed.
// Quit after it's done.
// Doesn't pass the callback js function to napi_create_threadsafe_function.
// Instead, use an alternative reference to get js function called.
.then(() => testWithJSMarshaller({
threadStarter: 'StartThreadNoJsFunc',
maxQueueSize: binding.MAX_QUEUE_SIZE,
quitAfter: binding.ARRAY_LENGTH
}))
.then((result) => assert.deepStrictEqual(result, expectedArray))
// Start the thread in blocking mode with an infinite queue, and assert that all
// values are passed. Quit after it's done.
.then(() => testWithJSMarshaller({