carryingFiber

Convenience function creating a new CarryingFiber while inferring the payload type T from the passed payload argument.

carryingFiber
(
T
FnOrDg
Args...
)
(
FnOrDg fnOrDg
,,
Args args
,
const string caller = __FUNCTION__
)
if (
isSomeFunction!FnOrDg &&
(
!Args.length ||
allSatisfy!(isNumeric, Args)
)
)

Parameters

T

Type to embed into the class as the type of CarryingFiber.payload.

fnOrDg FnOrDg

Function/delegate pointer to call when invoking the resulting CarryingFiber.

payload T

Payload to assign to the payload member of the resulting CarryingFiber.

args Args

Arguments to pass to the Fiber super constructor. If empty, its default arguments are used.

caller string

String name of the calling function creating the resulting CarryingFiber.

Return Value

Type: auto

A CarryingFiber with an automatically-inferred template parameter T, whose payload is set to the passed payload.

Examples

import kameloso.constants : BufferSize;

static struct Payload
{
    string s;
    int i;
}

void dg() {}

Payload payload;
payload.s = "Hello";
payload.i = 42;

auto fiber = carryingFiber(&dg, payload, BufferSize.fiberStack);
assert(fiber.payload == payload);
fiber.call();
assert(fiber.called == 1);