On Wed, 12 Mar 2014 22:50:03 +0100, Sönke Ludwig wrote:
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)[]
orshared(ulong)[]
for this
purpose, whereimmutable
here seems to be the most likely candidate
(either directly build the array as immutable, or use.idup
orassumeUnique
).If you ever have a situation where you are certain that it is safe to
pass some data to another thread, you can also usecast(immutable)
orcast(shared)
to talk the compiler into accepting it, but of course
this is unsafe and not recommended practice.
Sorry, I shouldn't have even posted that, it dawned on me as I was writing the post that I needed to add immutable to the function signature, but I had a mental breakdown and went ahead and posted after I had fixed the code.
Thanks though for you always helpful and informative responses.