pthread_timedjoin(), pthread_timedjoin_monotonic()
Join a thread, with a time limit
Synopsis:
#include <pthread.h>
int pthread_timedjoin(
pthread_t thread,
void** value_ptr,
const struct timespec* abstime );
int pthread_timedjoin_monotonic(
pthread_t thread,
void** value_ptr,
const struct timespec* abstime );
Arguments:
- thread
- The target thread whose termination you're waiting for.
- value_ptr
- NULL, or a pointer to a location where the function can store the value passed to pthread_exit() by the target thread.
- abstime
- A pointer to a timespec structure that specifies the absolute time at which the time-out is to expire.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The pthread_timedjoin() and pthread_timedjoin_monotonic() functions are QNX OS functions that are similar to the POSIX pthread_join() function, except that they give an error of ETIMEDOUT if the join doesn't occur before the absolute time specified by abstime passes (i.e., the system time is greater than or equal to abstime):
If you are not too long, I will wait here for you all my life.— Oscar Wilde, The Importance of Being Earnest
The pthread_timedjoin_monotonic() function uses CLOCK_MONOTONIC, so the timeout isn't affected by changes to the system time.
The pthread_timedjoin() and pthread_timedjoin_monotonic() functions block the calling thread until the target thread thread terminates, unless thread has already terminated. If value_ptr is non-NULL and the functions return successfully, then the value passed to pthread_exit() by the target thread is placed in value_ptr. If the target thread has been canceled, then value_ptr is set to PTHREAD_CANCELED.
The target thread must be joinable. Multiple pthread_join(), pthread_timedjoin(), pthread_timedjoin_monotonic(), ThreadJoin(), and ThreadJoin_r() calls on the same target thread aren't allowed. When pthread_timedjoin() or pthread_timedjoin_monotonic() returns successfully, the target thread has been terminated.
Returns:
- EOK
- Success.
- EBUSY
- The specified thread is already being joined by another thread.
- EDEADLK
- The calling thread is attempting to join itself.
- EFAULT
- A fault occurred when the kernel tried to access the buffers provided.
- EINVAL
- The specified thread isn't joinable because it's detached (see pthread_detach()).
- ESRCH
- The specified thread doesn't exist.
- ETIMEDOUT
- The absolute time specified in abstime passed before the join occurred.
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |