The OpenD Programming Language

TaskPool.put

Put a Task object on the back of the task queue. The Task object may be passed by pointer or reference.

  1. void put(Task!(fun, Args) task)
  2. void put(Task!(fun, Args)* task)
    class TaskPool
    void
    put
    (
    alias fun
    Args...
    )
    (
    Task!(fun, Args)* task
    )
    if (
    !isSafeReturn!(typeof(*task))
    )

Examples

import std.file;

// Create a task.
auto t = task!read("foo.txt");

// Add it to the queue to be executed.
taskPool.put(t);

Notes:

@trusted overloads of this function are called for Tasks if std.traits.hasUnsharedAliasing is false for the Task's return type or the function the Task executes is pure. Task objects that meet all other requirements specified in the @trusted overloads of task and scopedTask may be created and executed from @safe code via Task.executeInNewThread but not via TaskPool.

While this function takes the address of variables that may be on the stack, some overloads are marked as @trusted. Task includes a destructor that waits for the task to complete before destroying the stack frame it is allocated on. Therefore, it is impossible for the stack frame to be destroyed before the task is complete and no longer referenced by a TaskPool.

Meta