📄 threadevent.h
字号:
#ifndef __GradSoft_ThreadCondition_h#define __GradSoft_ThreadCondition_h/* * ThreadCondition * part of GradSoft C++ Threading toolbox * (C) GradSoft 2000, 2001 * $Id: ThreadEvent.h,v 1.8 2001/10/31 03:13:47 rssh Exp $ */#ifndef __GradSoft_ThreadingExceptions_h#include <GradSoft/ThreadingExceptions.h>#endif#ifndef __GradSoft_ThreadingUtils_h#include <GradSoft/ThreadingUtils.h>#endif#ifdef HAVE_PTHREAD_H#include <pthread.h>#endif#ifdef WIN32#include <windows.h>#endif/** * **/namespace GradSoft{#ifdef WIN32const int SIGNAL = 0;const int BROADCAST = 1;#endif/** * Thread Event class * (or in other terminology, ThreadCondition) **/class ThreadEvent{public: /// ThreadEvent() throw(ThreadingExceptions::NoResources, ThreadingExceptions::InternalError); /// ~ThreadEvent() throw(ThreadingExceptions::ResourceBusy, ThreadingExceptions::InternalError); /// void wait() throw(ThreadingExceptions::PossibleDeadlock, ThreadingExceptions::InternalError); /// void wait(long timeout) throw(ThreadingExceptions::PossibleDeadlock, ThreadingExceptions::InternalError); /// void notify() throw(); /// void notifyAll() throw();private:#ifdef WIN32 int waiters_count_; CRITICAL_SECTION waiters_count_lock_; CRITICAL_SECTION send_lock_; HANDLE events_[2];#else pthread_cond_t condition_; pthread_mutex_t internal_mutex_;#endif};}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -