node-ctypes - v2.17.1
    Preparing search index...

    Class Executor

    A native thread owned by node-ctypes, with a FIFO queue of calls.

    fn.callOn(executor, ...args) is fn.callAsync(...args) (same conversions, out parameters, errcheck and argument lifetime) run on this thread instead of a libuv worker: calls run one at a time, in arrival order, so a slow call never occupies the libuv pool (fs, dns, crypto) and calls that must share a thread (thread-local state, thread-affine handles) can.

    The thread starts with the first call. While calls are pending the process stays alive; an idle executor does not keep it alive and is collected with its thread when unreferenced. When the process exits (or a worker thread terminates) queued calls are discarded and the teardown waits for the running call to return (worker.terminate() resolves after it).

    A call that completes within the ExecutorOptions.spin budget is completed before callOn returns: its errcheck runs then, and the promise is already settled (await still resumes asynchronously).

    No Python equivalent.

    const executor = new Executor({ name: "device" });
    const result = await lib.slow_read.callOn(executor, handle, buffer, size);
    const controller = new AbortController();
    const next = lib.slow_read.callOn({ executor, signal: controller.signal }, handle, buffer, size);
    controller.abort(); // rejects `next` if it has not started
    await executor.close();
    Index
    pending: number

    Calls queued or running.

    completed: number

    Calls settled since the executor was created.

    running: boolean

    Whether the thread is running (started by the first call, stopped by close()).

    closed: boolean

    Whether close() has been called.

    • Reject new calls, wait for the accepted ones, then stop the thread. Always returns the same promise; a closed executor cannot be reopened.

      Returns Promise<void>