mr-edd.co.uk :: horsing around with the C++ programming language

async 0.2.2 released

[23rd September 2007]

In async 0.2.1, I added the ability to turn a future<> in to a future_scope allowing future<>s instantiated with different template parameters to be added to a single homogeneous container:

std::vector<async::future_scope> futs;

async::future<double> fd = async::call(cage, &func1, x, y, z);
async::future<std::string> fs = async::call(cage, &func2, a, b, c);

futs.push_back(fd.extend_lifetime());
futs.push_back(fs.extend_lifetime());

This is all well and good, but there was no way to get back to a future<> from a future_scope. Instead you had to resort to using Boost.Any, or something similar. In 0.2.2 this has changed.

There is now a future_cast<> function that allows you to get back to the future[1].

futs.push_back(fd.extend_lifetime());
futs.push_back(fs.extend_lifetime());

async::future<double> fd2 = async::future_cast<double>(futs[0]);
async::future<std::string> fs2 = async::future_cast<std::string>(futs[1]);

To find out more, head on over to the async project page.

Footnotes
  1. it's shameful how long it took me to work in that phrase with all my recent posts on futures []

Comments

(optional)
(optional)
(required, hint)

Links can be added like [this one -> http://www.mr-edd.co.uk], to my homepage.
Phrases and blocks of code can be enclosed in {{{triple braces}}}.
Any HTML markup will be escaped.