The OpenD Programming Language

task

Version of task usable from @safe code. Usage mechanics are identical to the non-@safe case, but safety introduces some restrictions:

1. fun must be @safe or @trusted.

2. F must not have any unshared aliasing as defined by std.traits.hasUnsharedAliasing. This means it may not be an unshared delegate or a non-shared class or struct with overloaded opCall. This also precludes accepting template alias parameters.

3. Args must not have unshared aliasing.

4. fun must not return by reference.

5. The return type must not have unshared aliasing unless fun is pure or the Task is executed via executeInNewThread instead of using a TaskPool.

  1. auto task(Args args)
  2. auto task(F delegateOrFp, Args args)
  3. auto task(F fun, Args args)
    @trusted
    task
    (
    F
    Args...
    )
    (
    F fun
    ,
    Args args
    )
    if (
    is(typeof(fun(args))) &&
    isSafeTask!F
    )

Meta