标签:des style blog color re div
#include <pthread.h> class CTestLock { public: CTestLock() { pthread_mutex_init(&mutex_t_, NULL); pthread_cond_init(&cond_t_, NULL); } ~CTestLock() { pthread_mutex_destroy(&mutex_t_); pthread_cond_destroy(&cond_t_); } int Lock() { int nRetCode = pthread_mutex_lock(&mutex_t_); return (nRetCode == 0); } int Unlock() { int nRetCode = pthread_mutex_unlock(&mutex_t_); return (nRetCode == 0); } int Wait() { int nRetCode = pthread_cond_wait(&cond_t_,&mutex_t_); return (nRetCode == 0); } int Signal() { int nRetCode = pthread_cond_signal(&cond_t_); return (nRetCode == 0); } int Broadcast() { int nRetCode = pthread_cond_broadcast(&cond_t_); return (nRetCode == 0); } private: pthread_mutex_t mutex_t_; pthread_cond_t cond_t_; };
标签:des style blog color re div
原文地址:http://www.cnblogs.com/youngt/p/3853058.html