INNER CODE UNIT · TypeScript

test

andywer/threads.js · test-tooling/webpack/app.ts:6

async function test() {
  const pool = Pool(() => spawn<HelloWorker>(new Worker("./pool-worker")))
  const results = await Promise.all([
    pool.queue(hello => hello("World")),
    pool.queue(hello => hello("World")),
    pool.queue(hello => hello("World")),
    pool.queue(hello => hello("World"))
  ])
  await pool.terminate()

  for (const result of results) {
    if (result !== "Hello, World") {
      throw Error("Unexpected result returned by pool worker: " + result)
    }
  }
}

async function test2() {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…