⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventdispatcher.h

📁 .net 方面的开发说明资料。
💻 H
字号:
// ========================================================
// Event Dispatching
//
// Design and Implementation by Floris van den Berg
// ========================================================

#ifndef EVENTDISPATCHER_H
#define EVENTDISPATCHER_H

#ifndef _LIST_
#include <list>
#endif

#ifndef _MAP_
#include <map>
#endif

#ifndef _VECTOR_
#include <vector>
#endif

#ifndef _MEMORY_
#include <memory>
#endif

#ifndef OPENNET_H
#include "OpenNet.h"
#endif

#ifndef BOOST_THREAD_WEK070601_HPP
#include <boost/thread/thread.hpp>
#endif

// --------------------------------------------------------

struct EpEventEx;
struct TransportEntry;
class ThreadBalancer;
class EventDispatcher;

// --------------------------------------------------------

typedef _STL::list<EpEventEx *> EventList;

// --------------------------------------------------------

struct DispatchFunctor {
public :
	DispatchFunctor(EventDispatcher *entry);
	bool operator()();
private :
	bool DispatchEvent(TransportEntry *plug_entry, GUID &guid, EpEvent *event);
public :
	EventDispatcher *m_entry;
};

// --------------------------------------------------------

class EventDispatcher {
	friend struct DispatchFunctor;
	friend struct SystemFunctor;

public :
	EpEventEx *createEventEntry(TRANSPORT_HANDLE transport, EpEvent *event);
	void pushEventEntry(EpEventEx *entry);
	void clearPendingEventEntries();
	void clearPendingEventEntries(TRANSPORT_HANDLE transport);
	void clearPendingEventEntries(TRANSPORT_HANDLE transport, CLSID protocol);
	void destroyEventEntry(EpEventEx *event);
	bool heartBeat();
	~EventDispatcher();

private :
	void setCallback(CallbackProc proc);
	void clearPendingEventEntries(EventList &list);
	void clearPendingEventEntries(TRANSPORT_HANDLE transport, EventList &list);
	void clearPendingEventEntries(TRANSPORT_HANDLE transport, CLSID protocol, EventList &list);

public :
	static EventDispatcher *getInstance();
	static bool isInstantiated();
	static void destroyInstance();

private :
	static EventDispatcher *instance;

private : // private constructor
	EventDispatcher();

private :
	DispatchFunctor *m_dispatch_functor;
	boost::mutex m_mutex;
	EventList m_event_list;
	DWORD m_time_stamp;
	DWORD m_delay;
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -