condvar.h

来自「天之炼狱1服务器端源文件游戏服务端不完整」· C头文件 代码 · 共 83 行

H
83
字号
//////////////////////////////////////////////////////////////////////// // CondVar.h // // by Reiot// ////////////////////////////////////////////////////////////////////////// represents Conditional Variable ( Thread Synchronization Primitive )////////////////////////////////////////////////////////////////////////#ifndef __COND_VAR_H__#define __COND_VAR_H__//////////////////////////////////////////////////// include files//////////////////////////////////////////////////#include "CondVarAttr.h"#include "Exception.h"#include "Mutex.h"#include "pthreadAPI.h"////////////////////////////////////////////////////////////////////////// class CondVar;////////////////////////////////////////////////////////////////////////class CondVar {//////////////////////////////////////////////////// constructor/destructor//////////////////////////////////////////////////public :		// constructor	CondVar ( CondVarAttr * attr = NULL ) throw ( Error );		// destructor	virtual ~CondVar () throw ( CondVarException , Error );	//////////////////////////////////////////////////// methods//////////////////////////////////////////////////public :		// wake up a waiting thread	void signal () throw ( Error );		// waiting until somebody wake up me	void wait ( Mutex & mutex ) throw ( Error );		//	// waiting until somebody wake up me or specified time elapsed	//	// *NOTES* 	// CondVarException means Timeout	//	void timedwait ( Mutex & mutex , const struct timespec * timeout ) 		throw ( CondVarException , InterruptedException , Error );		// wake up all waiting threads	void broadcast () throw ( Error );		// get raw conditional-variable object	pthread_cond_t * getCondVar () throw () { return &m_Cond; }//////////////////////////////////////////////////// attributes//////////////////////////////////////////////////private :		// raw conditional-variable object	pthread_cond_t m_Cond;	};#endif

⌨️ 快捷键说明

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