| 42 | } |
| 43 | |
| 44 | async function checkAcquire () { |
| 45 | const calls = []; |
| 46 | const { promise, createThread, stopThreads } = binding.threadsafe_function_sum.testAcquire(Array.prototype.push.bind(calls)); |
| 47 | for (let i = 0; i < THREAD_COUNT; i++) { |
| 48 | createThread(); |
| 49 | } |
| 50 | stopThreads(); |
| 51 | const result = await promise; |
| 52 | assert.ok(result); |
| 53 | assert.equal(sum(calls), EXPECTED_SUM); |
| 54 | } |
| 55 | |
| 56 | return check(binding.threadsafe_function_sum.testDelayedTSFN) |
| 57 | .then(() => check(binding.threadsafe_function_sum.testWithTSFN)) |