3
我有一个使用C++ 11期货的问题。当我在std::async
返回的未来上拨打wait()
或get()
时,程序将收到从mutex
标题中抛出的SIGABRT信号。可能是什么问题呢?如何解决它?SIGABRT从未来检索价值
我在Linux上使用g ++ 4.6。将以下代码粘贴到ideone.com会导致同样的问题。
#include <future>
#include <thread>
int calculate() {
return 1;
}
int main() {
auto result = std::async(calculate);
result.wait();// <-- this aborts
int value = result.get();// <-- or this aborts as well if previous line is commented out.
return 0;
}
也许看看这个:http://stackoverflow.com/questions/4426141/asynchronous-function-call-c0x –
@Anders K .:这似乎没有任何用处。如果它没有崩溃,我会对默认启动策略感到满意。 –