Open burner opened 5 years ago
std.parallelism is an excellent high-level version of Thread, but it has a few complaints.
It's difficult to specify the type of task when using member variables or managing tasks as arrays.
Task!Ret[] tasks;
tasks ~= task(()=>foo());
tasks ~= task(()=>bar());
I would also like to be able to specify the next process to be performed after the task is completed, like Promise in Javascript. It would also be nice to be able to branch on errors.
auto t1 = task(()=> foo());
auto t2 = t1.then( ()=> bar(), () => throw new Exception("foo() failed.") );
The `std.parallelism` package has been part of Phobos for a while now, and is in production use with many people/applications. Phobos generally has evolved since `std.parallelism` was created and there has been other work on fibers and co-routines in other packages within the D milieu. It would therefore seem a good time to review the tasks system at the heart of `std.parallelism` to see if there are improvements that can be made or general refactorings that are possible. Or it may be that the tasks system just needs some tweaks to improve performance. The issue here is that n active review of `std.parallelism` is due.