fastdo  0.5.12
winux::Condition类 参考

条件变量 更多...

#include <threads.hpp>

Public 成员函数

 Condition (bool isCreate=false)
 
 ~Condition ()
 
 Condition (Condition &&other)
 
Conditionoperator= (Condition &&other)
 
int create ()
 创建并初始化 更多...
 
int destroy ()
 销毁 更多...
 
bool wait (Mutex &mutex, double sec=-1)
 等待被通知 更多...
 
template<typename _Predicate >
bool waitUntil (_Predicate pred, Mutex &mutex, double sec=-1)
 等待谓词条件达成 更多...
 
int notify ()
 通知一个正在wait()中的线程醒来 更多...
 
int notifyAll ()
 通知所有正在wait()中的线程醒来 更多...
 
ConditionAttrattr ()
 

详细描述

条件变量

在文件 threads.hpp313 行定义.

构造及析构函数说明

winux::Condition::Condition ( bool  isCreate = false)
explicit
winux::Condition::~Condition ( )
winux::Condition::Condition ( Condition &&  other)

成员函数说明

ConditionAttr& winux::Condition::attr ( )
int winux::Condition::create ( )

创建并初始化

int winux::Condition::destroy ( )

销毁

int winux::Condition::notify ( )

通知一个正在wait()中的线程醒来

int winux::Condition::notifyAll ( )

通知所有正在wait()中的线程醒来

Condition& winux::Condition::operator= ( Condition &&  other)
bool winux::Condition::wait ( Mutex mutex,
double  sec = -1 
)

等待被通知

sec<1表示小于1秒的时间,sec<0表示无限等待。eg: sec=1.5表示等待1500ms 在mutex锁定之间调用,超时返回false。不满足条件请循环wait()。eg: while ( !条件 ) wait();

template<typename _Predicate >
bool winux::Condition::waitUntil ( _Predicate  pred,
Mutex mutex,
double  sec = -1 
)
inline

等待谓词条件达成

sec<1表示小于1秒的时间,sec<0表示无限等待。eg: sec=1.5表示等待1500ms 在mutex锁定之间调用,给定一个谓词描述条件达成,条件不达成就循环wait(),直到达成或超时,超时返回pred()。

在文件 threads.hpp339 行定义.


该类的文档由以下文件生成: