47#define cndOne ( false )
48#define cndAll ( true )
54typedef struct __cnd cnd_t;
61typedef struct __cnd cnd_id [];
77#define _CND_INIT() { _OBJ_INIT() }
85#define OS_CND( cnd ) \
86 cnd_t cnd[] = { _CND_INIT() }
89#define static_CND( cnd ) \
90 static cnd_t cnd[] = { _CND_INIT() }
114#define CND_CREATE() \
163int cnd_waitFor( cnd_t *cnd, mtx_t *mtx, cnt_t delay );
207void cnd_give( cnd_t *cnd,
bool all );
237#if defined(__cplusplus)
255 assert(_src.obj.queue ==
nullptr);
273 template<
typename T,
typename F>
274 int waitFor ( mtx_t& _mtx,
const T& _delay, F _stopWaiting )
281 template<
typename T,
typename F>
282 int waitUntil( mtx_t& _mtx,
const T& _time, F _stopWaiting )
286 if (result ==
E_TIMEOUT && _stopWaiting())
292 int wait ( mtx_t& _mtx, F _stopWaiting )
295 while (!_stopWaiting() && (result =
wait(_mtx)) ==
E_SUCCESS);
#define INFINITE
infinite waiting
Definition osbase.h:250
@ E_TIMEOUT
process was released as a result of the end of the timer countdown
Definition osbase.h:153
@ E_SUCCESS
process was released as a result of taking the supervising object
Definition osbase.h:150
cnt_t sys_time(void)
return current value of system counter
void cnd_notifyAll(cnd_t *cnd)
signal all tasks waiting on the condition variable
Definition osconditionvariable.h:228
int cnd_wait(cnd_t *cnd, mtx_t *mtx)
wait indefinitely on the condition variable releasing the currently owned mutex, and finally lock the...
Definition osconditionvariable.h:195
void cnd_init(cnd_t *cnd)
initialize a condition variable object
void cnd_reset(cnd_t *cnd)
reset the condition variable object and wake up all waiting tasks with 'E_STOPPED' event value
#define cndAll
notify all tasks (broadcast)
Definition osconditionvariable.h:48
void cnd_kill(cnd_t *cnd)
alias of cnd_reset()
Definition osconditionvariable.h:144
void cnd_notifyOne(cnd_t *cnd)
signal one task waiting on the condition variable
Definition osconditionvariable.h:217
int cnd_waitUntil(cnd_t *cnd, mtx_t *mtx, cnt_t time)
wait until given timepoint on the condition variable releasing the currently owned mutex,...
int cnd_waitFor(cnd_t *cnd, mtx_t *mtx, cnt_t delay)
wait for given duration of time on the condition variable releasing the currently owned mutex,...
void cnd_give(cnd_t *cnd, bool all)
signal one or all tasks that are waiting on the condition variable
#define cndOne
notify one task
Definition osconditionvariable.h:47
static constexpr rep until(const std::chrono::time_point< Clock, _Duration > &_time)
time point in ticks, rounded up to whole ticks (only a time point of this clock)
Definition osclock.h:109
static constexpr rep count(const std::chrono::duration< _Rep, _Period > &_delay)
delay in ticks, rounded up to whole ticks; negative delay: IMMEDIATE, delay out of range: INFINITE
Definition osclock.h:102
create and initialize a condition variable object
Definition osconditionvariable.h:244
void give(bool _all=cndAll)
cnd_give()
Definition osconditionvariable.h:268
void notifyAll()
cnd_notifyAll()
Definition osconditionvariable.h:270
int waitUntil(mtx_t &_mtx, const T &_time)
cnd_waitUntil()
Definition osconditionvariable.h:266
void reset()
cnd_reset()
Definition osconditionvariable.h:261
void notifyOne()
cnd_notifyOne()
Definition osconditionvariable.h:269
constexpr ConditionVariable()
constructor, see the constructor parameters of the class
Definition osconditionvariable.h:247
int waitFor(mtx_t &_mtx, const T &_delay)
cnd_waitFor()
Definition osconditionvariable.h:264
int wait(mtx_t &_mtx)
cnd_wait()
Definition osconditionvariable.h:267
void kill()
cnd_kill()
Definition osconditionvariable.h:262