Skip to content
Snippets Groups Projects
Commit 9a085f36 authored by Nadav Har'El's avatar Nadav Har'El
Browse files

Condvar: Allow condvar->wait() to take mutex reference

As a convenience, overload condvar->wait() to also take a mutex reference,
not just a mutex pointer.
parent f7d6e269
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ typedef struct condvar {
// In C++, for convenience also provide methods.
condvar() { memset(this, 0, sizeof *this); }
inline int wait(mutex_t *user_mutex, sched::timer *tmr = nullptr);
inline int wait(mutex_t &user_mutex, sched::timer *tmr = nullptr);
inline void wake_one();
inline void wake_all();
template <class Pred>
......@@ -71,6 +72,9 @@ int condvar_wait(condvar_t *condvar, mutex_t *user_mutex, sched::timer *tmr);
int condvar_t::wait(mutex_t *user_mutex, sched::timer *tmr) {
return condvar_wait(this, user_mutex, tmr);
}
int condvar_t::wait(mutex_t &user_mutex, sched::timer *tmr) {
return condvar_wait(this, &user_mutex, tmr);
}
void condvar_t::wake_one() {
return condvar_wake_one(this);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment