Oh, neat. This saves the day :) 2015-08-01 23:22 GMT+02:00 Ali Çehreli <digitalmars-d-learn@puremagic.com>:
> On 08/01/2015 08:37 AM, maarten van damme via Digitalmars-d-learn wrote: > >> I have a class that creates a task in it's constructor. How do I store >> this >> created task as one of it's value members and later on call .yieldForce()? >> >> > Tasks can be created with a function pointer 'function parameter' as well. > (This has already been added to "Programming in D" but it is not available > on the web site yet.) > > I learned the exact type by the help of pragma(msg) below and used it to > create MyTask and myTasks: > > import std.parallelism; > > double foo(int i) > { > return i * 1.5; > } > > double bar(int i) > { > return i * 2.5; > } > > void main() > { > auto tasks = [ task(&foo, 1), > task(&bar, 2) ]; // ← compiles > > pragma(msg, typeof(tasks[0])); > > alias MyTask = Task!(run, double function(int), int)*; > > MyTask[] myTasks; > myTasks ~= task(&foo, 1); > myTasks ~= task(&bar, 2); > } > > Ali > >