View source code
Display the source code in std/parallelism.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

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.

void put(alias fun, Args...) (
  ref 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 Tasks 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.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.

Authors

License

Boost License 1.0