Pantheios and boost::thread
Pantheios and boost::thread
我在使用带有 boost::threads 的 pantheios 日志记录库时遇到了一些问题。似乎如果我在创建线程之前使用任何 pantheios 日志记录,我会得到一个段错误。
例如,以下方法有效:
thread_ = new boost::thread(&foo);
pantheios::log(pantheios::debug, "Hello world");
但是,如果语句的顺序被切换,堆栈跟踪显示我在 boost 中崩溃start_thread
。
pantheios::log(pantheios::debug, "Hello world");
thread_ = new boost::thread(&foo);
// SEGFAULT!
有什么想法吗?
编辑:更多背景
int main()
{
pantheios::log(...);
MyClass myClass(/* some arguments, which are all literals */);
// Do some more work
return 0;
}
// MyClass constructor
MyClass::MyClass(/* args */)
: member1_(arg1)
, member2_(arg2)
{
thread_ = new boost::thread(&MyClass::workerLoop, this);
}
// Destructor
MyClass::~MyClass()
{
thread_->join();
delete thread_;
}
这将在start_thread
处出现段错误。再一次,如果我交换main
的两行,它将毫无问题地工作。
看来我想通了。我链接到不同版本的boost
.我的系统有 boost 版本 1.40,而我也在使用我下载的较新版本的 boost 1.49。值得注意的是,我链接的提升线程是旧版本的。
一旦我建立了链接以保持一致性,一切都按预期工作。
相关文章:
- 无法将参数传递给 boost::thread 构造函数
- 如何使用boost.thread运行多个接收器,每个线程应该分配给每个接收器?
- 使用 boost::thread 运行函子,但析构函数被错误地调用
- 最佳实践:我应该使用 std::thread、boost 还是本机调用
- boost::asio io_service thread pool with io_service::work
- 在thread.hpp上boost asio udp 螺纹= get_id()错误
- thread_specific_pointer可以在哪些平台上工作而无需 boost::thread?
- 将 boost::thread 与 C++11 std::mutex 混合使用是否安全?
- 同时使用 boost.python 和 boost.thread 时出现编译错误
- Boost.thread代码在Ubuntu和Windows中表现出不同的行为
- Pointer to boost::thread
- Linux上多核计算的低性能(openMP、boost::thread等)
- boost - thread.join() halts the ui
- 将基类的引用传递给 boost::thread 并在派生类中调用虚函数是否有效
- Difference between boost::thread and std::thread
- std::thread是boost::thread的替代品吗?
- 将 boost/thread headers 与 clang++ (Windows) 一起使用时出现问题
- 在linux下使用boost::thread创建一个boost::asio工作线程
- "Thread" Boost 无法在 OSX 上构建?
- C++ Boost::Thread & Boost::ASIO Memory leak