从future中检索值时SIGABRT
SIGABRT when retrieving value from future
我有一个使用c++ 11期货的问题。当我在std::async
返回的future上调用wait()
或get()
时,程序接收到从mutex
头抛出的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;
}
可以通过将-pthread
开关添加到g++
中来解决这个问题。
相关文章:
- 使用VerQueryValue检索应用程序的文件描述
- 是否可以从格式字符串中检索"width"
- 使用 pqxx 将 std::vector 存储在 postgresql 中,并从数据库中检索它
- 中止信号来自 C++ 中的中止(3) (SIGABRT)
- 如何在QByteArray中放置和检索位字段而不会感到痛苦?
- 如何在Qt中从数据库中检索二进制数据?
- 如何从C++代码中检索 QML 的文本字段中的文本?
- 从 opencv c++ 中的矢量中检索固定的帧数
- 如何在不等待检索的情况下获取C++中的内存位置?
- 如何在 QTreeWidget 中检索特定项目的 mimeData?
- C++从字符串中检索几行
- 在数据库中插入和检索矩阵
- 两个垫子的 OpenCV 数据是相同的,但使用 Mat::at 检索时的值已损坏
- 使用 const char* 键映射 C++ 检索空值
- 打印从SQLite3数据库检索的数据C++与命令行中相同的方式
- 如何检索指向在单独线程上运行的函数的移动指针?
- 如何检索 Steamwork SDK 的当前版本
- 通过 host() 从 af::array 检索数据会导致错误的数据
- 为什么我在此代码中收到 SIGABRT 错误
- 从future中检索值时SIGABRT