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

📄 warthreadevent.h

📁 ftpserver very good sample
💻 H
字号:
/** Event/Condition   This object allow one or more threads to wait for another  thread. The running thread signals the event, and one of  the locked threads unlocks and starts to execute.   In Win32 this is reffered to as Events. In pthread terminology  we are speaking about conditions.   The event can have two states, signaled and non/signaled.   Initially the state is non/signaled / which means that  WaitForEvent() will block. If the state is set to signaled,  WaitForEvent() will never block.    {\itThis object can not be used in static variables, as the constructor  needs to initialize the mutex.} */#ifndef WAR_THREAD_EVENT_H#define WAR_THREAD_EVENT_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_TYPES_H#   include "WarTypes.h"#endif#ifndef WAR_EXCEPTION_H#   include "WarException.h"#endif#ifndef WAR_CRITICAL_SECTION_H#   include "WarCriticalSection.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 WarThreadEvent {public:    enum WaitE    {#ifdef WIN32        WAIT_INFINITE = INFINITE#else        WAIT_INFINITE = 0xffffffff#endif    };    enum StateE    {        EVENT_NONSIGNALED,        EVENT_SIGNALED    };    // LIFECYCLE        /**    * Default constructor.    */    WarThreadEvent(bool isAutoMode = false) throw(WarException);            /**    * Destructor.    */    ~WarThreadEvent(void);        // OPERATORS            // OPERATIONS    /// Lock until the event is signaled, or timeout. Returns false if timeout.    bool WaitForEvent (const war_uint32_t         millisecondsToWait = WAIT_INFINITE)        throw(WarException);    // Signal the event, unlocks one blocking thread    void Signal() throw(WarException);    /// Sets the event to signaled or non/signaled    void SetEvent(StateE newState);    // ACCESS    // INQUIRY    protected:private:    war_event_handle_t mEventHandle; // Event under Win32, Condition under UNIX    WarCriticalSection mLock;#ifdef _DEBUG    int mNumBlockedThreads;#endif#if THREAD_PTHREAD    bool mIsSignaled;#endif};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* WAR_THREAD_EVENT_H_ */

⌨️ 快捷键说明

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