首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

怎的封装一个pthread_cond_t类

2012-08-07 
怎样封装一个pthread_cond_t类我封装了一个互斥锁的类,如下:class CThreadMutex{friend class CCondition

怎样封装一个pthread_cond_t类
我封装了一个互斥锁的类,如下:
class CThreadMutex
{
friend class CCondition;

public:
CThreadMutex()
{
pthread_mutex_init(&m_pthreadMutex, NULL);

}
~CThreadMutex()
{
pthread_mutex_destroy(&m_pthreadMutex);
}
void lock()
{
pthread_mutex_lock(&m_pthreadMutex);
}
void unlock()
{
pthread_mutex_unlock(&m_pthreadMutex);  
}
private:
pthread_mutex_t m_pthreadMutex;
};
现在想封装一个条件变量的类,但是pthread_cond_wait里有一个互斥锁的变量,我知道该怎么封装。利用pthread库里的函数pthread_cond_init, pthread_cond_destroy, pthread_cond_signal,pthread_cond_wait



[解决办法]

google 去吧

热点排行