📄 timeoutmanager.h
字号:
// ========================================================
// Event time-out handler
//
// Design and Implementation by Floris van den Berg
// ========================================================
#ifndef TIMEOUTMANAGER_H
#define TIMEOUTMANAGER_H
#ifndef BOOST_THREAD_WEK070601_HPP
#include <boost/thread/thread.hpp>
#endif
// --------------------------------------------------------
struct TimeOutEvent;
struct ITransport;
class Event;
class TimeOutManager;
// --------------------------------------------------------
typedef _STL::list<TimeOutEvent> TimeOutList;
// --------------------------------------------------------
struct TimeOutEvent {
ITransport *m_plug;
GUID m_protocol;
int m_msg;
unsigned int m_timeout;
unsigned int m_start_time;
TimeOutEvent() :
m_plug(0),
m_protocol(CLSID_NULL_PROTOCOL),
m_msg(0),
m_timeout(0),
m_start_time(0) {
}
};
// --------------------------------------------------------
struct TimeOutFunctor {
public :
TimeOutFunctor(TimeOutManager *timeout);
void operator()();
bool iterate();
private :
TimeOutManager *m_manager;
};
// --------------------------------------------------------
class TimeOutManager {
friend struct TimeOutFunctor;
public :
void addItem(ITransport *plug, EpAction *action);
bool removeItem(ITransport *plug, GUID protocol, int msg);
bool removeItems();
bool removeItems(ITransport *plug);
bool removeItems(ITransport *plug, GUID protocol);
bool timeOutsQueued();
~TimeOutManager();
public :
static TimeOutManager *getInstance();
static bool isInstantiated();
static void destroyInstance();
private :
TimeOutManager();
private :
static TimeOutManager *instance;
private :
boost::thread *m_thread;
bool m_thread_running;
boost::mutex m_cs;
TimeOutList m_queue;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -