Function runWorkerTask
Runs a new asynchronous task in a worker thread.
Only function pointers with weakly isolated arguments are allowed to be able to guarantee thread-safety.
Prototypes
void runWorkerTask(R, ARGS...)( R function(ARGS) func, ARGS args ); void runWorkerTask(alias method, T, ARGS...)( shared(T) object, ARGS args );
Example
Running a worker task using a function
static void workerFunc(int param) { logInfo("Param: %s", param); } static void test() { runWorkerTask(&workerFunc, 42); }
Example
Running a worker task using a class method
static class Test { void workerMethod(int param) shared { logInfo("Param: %s", param); } } static void test() { auto cls = new shared Test; runWorkerTask!(Test.workerMethod)(cls, 42); }
Authors
Sönke Ludwig
Copyright
© 2012-2014 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.