This is a wrapper around Gnulib's glthread functionality.
It currently supports Posix threads (pthreads), GNU Pth threads, Solaris threads and Windows threads.
◆ wget_thread_mutex_init()
- Parameters
-
[in,out] | mutex | The mutex to initialize |
- Returns
- 0 on success, non-zero on failure
Initializes the mutex
.
After usage, a call to wget_thread_mutex_destroy() frees the allocated resources.
◆ wget_thread_mutex_destroy()
- Parameters
-
[in,out] | mutex | The mutex to destroy |
- Returns
- 0 on success, non-zero on failure
Free's the mutex
and it's resources.
After calling this function, the mutex
cannot be used any more.
◆ wget_thread_mutex_lock()
◆ wget_thread_mutex_unlock()
- Parameters
-
[in] | mutex | The mutex to be unlocked |
Unlocks the mutex
.
◆ wget_thread_cond_init()
- Parameters
-
[in,out] | cond | The conditional to initialize |
- Returns
- 0 on success, non-zero on failure
Initializes the conditional cond
.
After usage, a call to wget_thread_cond_destroy() frees the allocated resources.
◆ wget_thread_cond_destroy()
- Parameters
-
[in,out] | cond | The conditional to destroy |
- Returns
- 0 on success, non-zero on failure
Free's the conditional cond
and it's resources.
After calling this function, cond
cannot be used any more.
◆ wget_thread_cond_signal()
- Parameters
-
[in] | cond | The conditional to signal a condition |
- Returns
- 0 on success, non-zero on failure
Wakes up one (random) thread that waits on the conditional.
◆ wget_thread_cond_wait()
- Parameters
-
[in] | cond | The conditional to wait for |
[in] | mutex | The mutex needed for thread-safety |
[in] | ms | The wait timeout in milliseconds |
- Returns
- 0 on success, non-zero on failure
Waits for a condition with a max. timeout of ms
milliseconds.
To wait forever use a timeout lower or equal then 0.
◆ wget_thread_start()
int wget_thread_start |
( |
wget_thread * |
thread, |
|
|
void *(*)(void *) |
start_routine, |
|
|
void * |
arg, |
|
|
WGET_GCC_UNUSED int |
flags |
|
) |
| |
- Parameters
-
[out] | thread | The thread variable to be initialized |
[in] | start_routine | The thread function to start |
[in] | arg | The argument given to start_routine |
[in] | flags | Currently unused |
- Returns
- 0 on success, non-zero on failure
Start start_routine
as own thread with argument arg
.
◆ wget_thread_cancel()
int wget_thread_cancel |
( |
WGET_GCC_UNUSED wget_thread |
thread | ) |
|
- Parameters
-
[in] | thread | Thread to cancel |
- Returns
- 0 on success, non-zero on failure
Currently a no-op function, since it's not portable.
◆ wget_thread_kill()
int wget_thread_kill |
( |
WGET_GCC_UNUSED wget_thread |
thread, |
|
|
WGET_GCC_UNUSED int |
sig |
|
) |
| |
- Parameters
-
[in] | thread | Thread to send the signal to |
[in] | sig | Signal to send |
- Returns
- 0 on success, non-zero on failure
Currently a no-op function, since it's not portable.
◆ wget_thread_join()
- Parameters
-
[in] | thread | Thread to wait for |
- Returns
- 0 on success, non-zero on failure
Wait until the thread
has been stopped.
This function just waits - to stop a thread you have take your own measurements.
◆ wget_thread_self()
wget_thread_id wget_thread_self |
( |
void |
| ) |
|
- Returns
- The thread id of the caller.
◆ wget_thread_support()
bool wget_thread_support |
( |
void |
| ) |
|
- Returns
- Whether libwget supports multi-threading on this platform or not.