I have a problem using C++11 futures. When I call wait()
or get()
on the future returned by std::async
, the program receives SIGABRT signal thrown from the mutex
header. What could be the problem? How to fix it?
I use g++ 4.6 on Linux. Pasting the following code to ideone.com causes the same problem.
#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;
}