Skip to content

Commit

Permalink
Add z_condvar_timedwait function
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed Sep 15, 2024
1 parent 5b9b415 commit 7049dcc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/zenoh-pico/system/platform-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ int8_t _z_condvar_drop(_z_condvar_t *cv);
int8_t _z_condvar_signal(_z_condvar_t *cv);
int8_t _z_condvar_signal_all(_z_condvar_t *cv);
int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m);
int8_t _z_condvar_timedwait(_z_condvar_t *cv, _z_mutex_t *m, const z_clock_t *abstime);

_Z_OWNED_TYPE_VALUE(_z_condvar_t, condvar)
_Z_OWNED_FUNCTIONS_SYSTEM_DEF(condvar)
Expand All @@ -129,6 +130,7 @@ int8_t z_condvar_drop(z_moved_condvar_t *cv);

int8_t z_condvar_signal(z_loaned_condvar_t *cv);
int8_t z_condvar_wait(z_loaned_condvar_t *cv, z_loaned_mutex_t *m);
int8_t z_condvar_timedwait(z_loaned_condvar_t *cv, z_loaned_mutex_t *m, const z_clock_t *abstime);

/*------------------ Sleep ------------------*/
int z_sleep_us(size_t time);
Expand Down
3 changes: 3 additions & 0 deletions src/system/platform-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@ int8_t z_condvar_drop(z_moved_condvar_t *cv) { return _z_condvar_drop(&cv->_this

int8_t z_condvar_signal(z_loaned_condvar_t *cv) { return _z_condvar_signal(cv); }
int8_t z_condvar_wait(z_loaned_condvar_t *cv, z_loaned_mutex_t *m) { return _z_condvar_wait(cv, m); }
int8_t z_condvar_timedwait(z_loaned_condvar_t *cv, z_loaned_mutex_t *m, const z_clock_t *abstime) {
return _z_condvar_timedwait(cv, m, abstime);
}

#endif // Z_FEATURE_MULTI_THREAD == 1
4 changes: 4 additions & 0 deletions src/system/unix/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ int8_t _z_condvar_signal(_z_condvar_t *cv) { _Z_CHECK_SYS_ERR(pthread_cond_signa
int8_t _z_condvar_signal_all(_z_condvar_t *cv) { _Z_CHECK_SYS_ERR(pthread_cond_broadcast(cv)); }

int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { _Z_CHECK_SYS_ERR(pthread_cond_wait(cv, m)); }

int8_t _z_condvar_timedwait(_z_condvar_t *cv, _z_mutex_t *m, const z_clock_t *abstime) {
_Z_CHECK_SYS_ERR(pthread_cond_timedwait(cv, m, abstime));
}
#endif // Z_FEATURE_MULTI_THREAD == 1

/*------------------ Sleep ------------------*/
Expand Down

0 comments on commit 7049dcc

Please sign in to comment.