LibPthread: Hookup abstime argument to pthread_cond_timedwait
Now that the futex implementation actually supports timeouts, we can fix the LibPthread implementation of pthread_cond_timedwait to support the timeout argument.
This commit is contained in:
parent
25a620a573
commit
6116739b38
Notes:
sideshowbarker
2024-07-19 07:15:49 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/6116739b38b Pull-request: https://github.com/SerenityOS/serenity/pull/1964 Reviewed-by: https://github.com/awesomekling
1 changed files with 10 additions and 7 deletions
|
@ -485,14 +485,20 @@ int pthread_cond_destroy(pthread_cond_t*)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex)
|
||||
static int cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex, const struct timespec* abstime)
|
||||
{
|
||||
i32 value = cond->value;
|
||||
cond->previous = value;
|
||||
pthread_mutex_unlock(mutex);
|
||||
int rc = futex(&cond->value, FUTEX_WAIT, value, nullptr);
|
||||
ASSERT(rc == 0);
|
||||
int rc = futex(&cond->value, FUTEX_WAIT, value, abstime);
|
||||
pthread_mutex_lock(mutex);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex)
|
||||
{
|
||||
int rc = cond_wait(cond, mutex, nullptr);
|
||||
ASSERT(rc == 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -515,10 +521,7 @@ int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock)
|
|||
|
||||
int pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, const struct timespec* abstime)
|
||||
{
|
||||
// FIXME: Implement timeout.
|
||||
(void)abstime;
|
||||
pthread_cond_wait(cond, mutex);
|
||||
return 0;
|
||||
return cond_wait(cond, mutex, abstime);
|
||||
}
|
||||
|
||||
int pthread_cond_signal(pthread_cond_t* cond)
|
||||
|
|
Loading…
Add table
Reference in a new issue