Creating a future/promise object

Justin Whear via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 6 15:18:02 PDT 2015


On Mon, 06 Jul 2015 20:56:03 +0000, Frank Pagliughi wrote:

> Hello All,
> 
> I'm trying to figure out how to create a shared object that can be used
> to track asynchronous operations. Something that can be used like:
> 
>    Token tok = mything.start_something();
> 
>    // do something else for a while
> 
>    int n = tok.get_result();  // Block until result is ready
> 

std.parallelism.Task implements the high-level pattern you're looking for:
http://dlang.org/phobos/std_parallelism.html#.Task


More information about the Digitalmars-d mailing list