FiberScheduler.spawnWithToken

TaskHandle spawnWithToken(void delegate() fn, CancelToken token, string name = null) @trusted

Spawn a new fiber task with a cancellation token.

If the token is already cancelled at spawn time, the task is immediately marked CANCELLED and never runs. Otherwise, the scheduler checks the token before each resume in tick().

Parameters

fnThe delegate to execute in the fiber context.
tokenCancellation token to observe.
nameOptional name for the task.

Returns

A TaskHandle that can be used to monitor or cancel the task.