test: add test for effect of UV_THREADPOOL_SIZE
This (not particularly elegant) native addon tests the effect of UV_THREADPOOL_SIZE
on node-api. The test fails if Node.js allows more than UV_THREADPOOL_SIZE
async tasks to run concurrently, or if it limits the number of concurrent async tasks to anything less than UV_THREADPOOL_SIZE
.
The test schedules UV_THREADPOOL_SIZE + 1
async tasks and waits until UV_THREADPOOL_SIZE
tasks are running concurrently. (If this never happens, the test times out.) All UV_THREADPOOL_SIZE
tasks then wait for a second to see if the last task also starts running concurrently, which should not happen.
Admittedly, I hastily put this together and the code is sloppy. While having this test is good in any case, the main motivation is such that @anonrig can invoke the test from his own test in https://github.com/nodejs/node/pull/48890.