Reputation: 363
come across this excellent ActiveObject example in http://www.paulbridger.com/active_object/
I tried, but get only the following output:
Dispatching...
Waiting for results...
Wondering why waiting for results? Do I need to do anything in the Servant::doSomeWork()?
Upvotes: 0
Views: 1380
Reputation: 16168
You can actually do with with the standard.
If you have c++0x (try -std=c++0x compiler flag or check your man file).
int main()
{
auto future_int=std::async(std::launch::async, []()->int{
//whatever you want in here
return do_work(); //or whatever you need to do
});
//do other stuff
std::cout << future_int.get() << std::endl;
}
Upvotes: 1