openMP

David Nadlinger see at klickverbot.at
Wed Oct 3 08:50:46 PDT 2012


On Wednesday, 3 October 2012 at 14:10:57 UTC, dsimcha wrote:
> Unless we're using different terminology here, futures are just 
> std.parallelism Tasks.

No, std.parallelism.Tasks are not really futures – they offer a 
constrained [1] future interface, but couple this with the notion 
that a Task can be executed at some point on a TaskPool chosen by 
the user. Because of this, I had to implement my own futures for 
the Thrift async stuff, where I needed a future as a promise [2] 
by an invoked entity that it kicked off a background activity 
which will eventually return a value, but which the users can't 
»start« or choose to »execute it now«, as they can with Tasks.

If TaskPool had an execute() method which took a delegate to 
execute (or a »Task«, for that matter) and returned a new 
object which serves as a »handle« with wait()/get()/… 
methods, _that_ would (likely) be a future.

David


[1] Constrained in the sense that it is only meant for 
short-/synchronous-running tasks and thus e.g. offer no callback 
mechanism.

[2] Let's not get into splitting hairs regarding the exact 
meaning of »Future« vs. »Promise«, especially because C++11 
introduced a new interpretation to the mix.


More information about the Digitalmars-d mailing list