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.
Prototypes
void put(alias fun, Args...)( Task!(fun,Args) task ) if (!isSafeReturn!(typeof(task))); void put(alias fun, Args...)( Task!(fun,Args)* task ) if (!isSafeReturn!(typeof(*task)));
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
s if
Task
std.traits.hasUnsharedAliasing
is false for the
's
return type or the function the Task
executes is Task
pure
.
objects that meet all other requirements specified in the
Task
@trusted
overloads of
and task
may be created
and executed from scopedTask
@safe
code via
but
not via Task.executeInNewThread
.
TaskPool
While this function takes the address of variables that may
be on the stack, some overloads are marked as @trusted.
includes a destructor that waits for the Task
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