12 Star 34 Fork 1

whb-helloworld/112

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Cond.hpp 818 Bytes
一键复制 编辑 原始数据 按行查看 历史
gitTest-比特科技 提交于 2个月前 . socket tcp
#pragma once
#include <iostream>
#include <pthread.h>
#include "Mutex.hpp"
namespace CondModule
{
using namespace LockModule;
class Cond
{
public:
Cond()
{
int n = ::pthread_cond_init(&_cond, nullptr);
(void)n;
}
void Wait(Mutex &lock) // 让我们的线程释放曾经持有的锁!
{
int n = ::pthread_cond_wait(&_cond, lock.LockPtr());
}
void Notify()
{
int n = ::pthread_cond_signal(&_cond);
(void)n;
}
void NotifyAll()
{
int n = ::pthread_cond_broadcast(&_cond);
(void)n;
}
~Cond()
{
int n = ::pthread_cond_destroy(&_cond);
}
private:
pthread_cond_t _cond;
};
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/whb-helloworld/112.git
git@gitee.com:whb-helloworld/112.git
whb-helloworld
112
112
master

搜索帮助

371d5123 14472233 46e8bd33 14472233