task to schedule and wait for
optional delegate called after task finishes but before it gets recycled, can be used to copy some data into caller fiber context
void example ( ) { static class ExampleTask : Task { mstring data; override void run ( ) { // do things that may result in suspending ... data = "abcd".dup; } override void recycle ( ) { this.data = null; } } mstring data; theScheduler.await( new ExampleTask, (Task t) { // copy required data before tasks gets recycled auto task = cast(ExampleTask) t; data = task.data.dup; } ); test!("==")(data, "abcd"); }
Schedules the argument and suspends calling task until the argument finishes.
This method must not be called outside of a task.
If task is already scheduled, it will not be re-scheduled again but awaiting will still occur.