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 .:這似乎沒有任何用處。如果它沒有崩潰,我會對默認啓動策略感到滿意。 –