Scheduler.awaitResult

Convenience shortcut on top of await to await for a task and return some value type as a result.

If task is already scheduled, it will not be re-scheduled again but awaiting will still occur.

Parameters

task TaskT

any task that defines result public field of type with no indirections

Return Value

Type: typeof(TaskT.result)

content of result field of the task read right after that task finishes

Examples

void example ( )
{
    static class ExampleTask : Task
    {
        int result;

        override void run ( )
        {
            // do things that may result in suspending ...
            this.result = 42;
        }

        override void recycle ( )
        {
            this.result = 43;
        }
    }

    auto data = theScheduler.awaitResult(new ExampleTask);
    test!("==")(data, 42);
}

Meta