[Issue 20858] New: std.parallelism.task: Can't move value to task param
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat May 23 15:37:09 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20858
Issue ID: 20858
Summary: std.parallelism.task: Can't move value to task param
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: blocker
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: nin-jin at ya.ru
src\phobos\std\parallelism.d(444,29): Error: struct jin.go.Output!long.Output
is not copyable because it is annotated with @disable
src\phobos\std\parallelism.d(832,16): Error: template instance
std.parallelism.Task!(wrapper, void function(Output!long) @system, Output!long)
error instantiating
Problem in this phobos code:
private static void impl(void* myTask)
{
import std.algorithm.internal : addressOf;
Task* myCastedTask = cast(typeof(this)*) myTask;
static if (is(ReturnType == void))
{
fun(myCastedTask._args); // !!!
}
else static if (is(typeof(&(fun(myCastedTask._args)))))
{
myCastedTask.returnVal = addressOf(fun(myCastedTask._args));
}
else
{
myCastedTask.returnVal = fun(myCastedTask._args);
}
}
See workaround in VibeD to call function with move semantic:
https://github.com/vibe-d/vibe-core/blob/master/source/vibe/core/taskpool.d#L210
mixin(callWithMove!ARGS("c", "args.expand")); // !!!
package string callWithMove(ARGS...)(string func, string args)
{
import std.string;
string ret = func ~ "(";
foreach (i, T; ARGS) {
if (i > 0) ret ~= ", ";
ret ~= format("%s[%s]", args, i);
static if (needsMove!T) ret ~= ".move";
}
return ret ~ ");";
}
--
More information about the Digitalmars-d-bugs
mailing list