0

在http://www.paulbridger.com/active_object/中遇到这个出色的 ActiveObject 示例

我试过了,但只得到以下输出:

Dispatching...
Waiting for results...

想知道为什么要等待结果?我需要在 Servant::doSomeWork() 中做任何事情吗?

4

1 回答 1

1

您实际上可以使用标准。

如果您有 c++0x(尝试 -std=c++0x 编译器标志或检查您的 man 文件)。

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;
}
于 2012-02-29T14:54:03.697 回答