Function std.parallelism.TaskPool.put
Put a Task
object on the back of the task queue. The Task
object may be passed by pointer or reference.
Example
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 Task
s if
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
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
.