📄 warsvrwin32ntengine.h
字号:
/** The WarSvrWin32NtEngine is a support-class for optimal performance and scalability for server applications under Windows NT. It's requiered by WarSocketIoWin32Nt. The object creates and maintains the therads used to process requests from clients and all other I/O Completion ports used by WarSocketIoWin32Nt It also maintains a seperate thread-pool with WarSvrWin32EventThread's to simulate I/O Completion ports for the socket connect() call. Send, receive and accept have native support for IOCP's. Conect does mot, so we use event notofications, and bypas the 64 event limit in WaitForMultipleObjects() by using a pool of threads, each waiting for up to 63 connections and one event for command notifications to the thread. The pool will dynamically add and remove threads, depending on the activity.*/#ifndef WAR_SVR_WIN32_NT_ENGINE_H#define WAR_SVR_WIN32_NT_ENGINE_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_THREAD_POOL_H# include "WarThreadPool.h"#endif#ifndef WAR_SVR_WIN32_EVENT_THREAD_H# include "WarSvrWin32EventThread.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarSvrWin32NtEngine : public WarThreadPool{public: typedef WarPtrWrapper<WarSvrWin32EventThread> iothread_ptr_t; typedef std::list<iothread_ptr_t> thread_list_t; // LIFECYCLE /** * Default constructor. */ WarSvrWin32NtEngine(void); /** * Destructor. */ ~WarSvrWin32NtEngine(void); // OPERATORS /** * Assignment operator. * * @param from THe value to assign to this object. * * @return A reference to this object. */ WarSvrWin32NtEngine& operator=(WarSvrWin32NtEngine& from); // OPERATIONS virtual void Create(war_uint32_t MinThreads = 16, war_uint32_t MaxThreads = 255) throw(WarException); // Workaround to emulate Connect() using I/O Completion ports void QueueRequest(WarSvrWin32EventThread::task_ptr_t& taskPtr); void RemoveRequest(const war_socket_t sck); void RemoveIdleEventThread(WarSvrWin32EventThread *pThread); // ACCESS /// Returns the I/O Completion port inline HANDLE GetPort() { if (mhIocp == NULL) WarThrow(WarError(WAR_ERR_INTERNAL_DATA_NOT_INITIALIZED), NULL); return mhIocp; } static WarSvrWin32NtEngine& GetEngine() { if (mspThis == NULL) WarThrow(WarError(WAR_ERR_INTERNAL_DATA_NOT_INITIALIZED), NULL); return *mspThis; } // INQUIRY protected: thread_list_t mIoThreads; WarCriticalSection mLock; friend class WarShutdownEngine; static void OnShutdown(war_cptr_t ptr);private: HANDLE mhIocp; // I/O completion port to use static WarSvrWin32NtEngine *mspThis;};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_SVR_WIN32_NT_ENGINE_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -