Reactor.deferToThread

run a function inside a different thread.

Runs a function inside a thread. Use this function to run CPU bound processing without freezing the other fibers.

Fini, if provided, will be called with the same parameters in the reactor thread once the thread has finished. Fini will be called unconditionally, even if the fiber that launched the thread terminates before the thread has finished.

The Fini function runs within a criticalSection, and must not sleep.

  1. auto deferToThread(Parameters!F args, Timeout timeout)
    struct Reactor
    @nogc
    deferToThread
    (
    alias Fini = null
    )
  2. auto deferToThread(F dlg, Timeout timeout)

Return Value

Type: auto

The return argument from the delegate is returned by this function.

Throws

Will throw TimeoutExpired if the timeout expires.

Will rethrow whatever the thread throws in the waiting fiber.

Meta