Am 12.03.2014 22:22, schrieb Craig Dillabaugh:
(...)
So I've attempted to try runWorkerTask, I have the following code to run my classifyTask:runWorkerTask( &classifyTask, bands.idup, "cluster", "isoclus.out.json", image_dir, image); //source/app.d(361)
But this fails with
Error: static assert "Argument type ulong[] is not safe to pass between threads." source/app.d(361): instantiated from here: runWorkerTask!(void, ulong[], string, string, string, ImageDB)
Is there any way to pass an array to a function run in runWorkerTask?
You can either use immutable(ulong)[]
or shared(ulong)[]
for this
purpose, where immutable
here seems to be the most likely candidate
(either directly build the array as immutable, or use .idup
or assumeUnique
).
If you ever have a situation where you are certain that it is safe to
pass some data to another thread, you can also use cast(immutable)
or cast(shared)
to talk the compiler into accepting it, but of course
this is unsafe and not recommended practice.