Something went wrong. Try again.
Offload functions to worker threads with shared memory primitives for Node.js.
Something went wrong. Try again.
478 B · 12 lines
TypeScript
at main
12345678910111213import { createServer } from 'node:http';import { threadId } from 'node:worker_threads';import { mo } from '../../src/index.ts';import { listen, type ListenArgs } from '../../src/serve/index.ts';
export const runServer = mo(import.meta, async (...args: ListenArgs): Promise<void> => { const srv = createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end(`handled by thread ${threadId}\n`); }); await listen(srv, ...args);});