我想在使用boost :: dll :: shared_library加载的DLL中使用Boost-Deadlinetimer。以下代码片段被简化为基本要素。在Windows DLL中使用boost :: asio :: deadline_timer时出现死锁
example.h文件:
#include <boost/asio.hpp>
class Example
{
public:
Class() : m_timer(m_ioService) { }
virtual ~Class() { }
//...
private:
boost::asio::io_service m_ioService;
boost::asio::deadline_timer m_timer;
//...
};
Example.cpp:
#include "Example.h"
#include <boost/config.hpp>
//...
extern "C" BOOST_SYMBOL_EXPORT Example MyExample;
Example MyExample;
Main.cpp的:
#include <boost/dll/Import.hpp>
//...
boost::dll::shared_library lib("Example.dll", boost::dll::load_mode::Default_mode);
//...
我的问题是,有一个僵局,而加载的dll编译只要m_timer
在构造函数的初始化列表中。
当由boost::shared_ptr
替换m_timer
和初始化,在构造(或随后的功能),那么就没有死锁而装载的dll但死锁而卸载该DLL。
无论如何,我不能真正使用Windows DLL中的全局截止时间定时器对象。