.TH "libwget-thread" 3 "Tue Jan 26 2021" "Version 1.99.1" "wget2" \" -*- nroff -*- .ad l .nh .SH NAME libwget-thread \- Implementation of multi-threading basic functionality .SH SYNOPSIS .br .PP .SS "Functions" .in +1c .ti -1c .RI "int \fBwget_thread_mutex_init\fP (wget_thread_mutex_t *mutex)" .br .ti -1c .RI "int \fBwget_thread_mutex_destroy\fP (wget_thread_mutex_t *mutex)" .br .ti -1c .RI "void \fBwget_thread_mutex_lock\fP (wget_thread_mutex_t mutex)" .br .ti -1c .RI "void \fBwget_thread_mutex_unlock\fP (wget_thread_mutex_t mutex)" .br .ti -1c .RI "int \fBwget_thread_cond_init\fP (wget_thread_cond_t *cond)" .br .ti -1c .RI "int \fBwget_thread_cond_destroy\fP (wget_thread_cond_t *cond)" .br .ti -1c .RI "int \fBwget_thread_cond_signal\fP (wget_thread_cond_t cond)" .br .ti -1c .RI "int \fBwget_thread_cond_wait\fP (wget_thread_cond_t cond, wget_thread_mutex_t mutex, long long ms)" .br .ti -1c .RI "int \fBwget_thread_start\fP (wget_thread_t *thread, void *(*start_routine)(void *), void *arg, G_GNUC_WGET_UNUSED int flags)" .br .ti -1c .RI "int \fBwget_thread_cancel\fP (G_GNUC_WGET_UNUSED wget_thread_t thread)" .br .ti -1c .RI "int \fBwget_thread_kill\fP (G_GNUC_WGET_UNUSED wget_thread_t thread, G_GNUC_WGET_UNUSED int sig)" .br .ti -1c .RI "int \fBwget_thread_join\fP (wget_thread_t *thread)" .br .ti -1c .RI "wget_thread_id_t \fBwget_thread_self\fP (void)" .br .ti -1c .RI "bool \fBwget_thread_support\fP (void)" .br .in -1c .SH "Detailed Description" .PP This is a wrapper around Gnulib's glthread functionality\&. .PP It currently supports Posix threads (pthreads), GNU Pth threads, Solaris threads and Windows threads\&. .SH "Function Documentation" .PP .SS "int wget_thread_mutex_init (wget_thread_mutex_t * mutex)" .PP \fBParameters\fP .RS 4 \fImutex\fP The mutex to initialize .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Initializes the \fCmutex\fP\&. .PP After usage, a call to \fBwget_thread_mutex_destroy()\fP frees the allocated resources\&. .SS "int wget_thread_mutex_destroy (wget_thread_mutex_t * mutex)" .PP \fBParameters\fP .RS 4 \fImutex\fP The mutex to destroy .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Free's the \fCmutex\fP and it's resources\&. .PP After calling this function, the \fCmutex\fP cannot be used any more\&. .SS "void wget_thread_mutex_lock (wget_thread_mutex_t mutex)" .PP \fBParameters\fP .RS 4 \fImutex\fP The mutex to be locked .RE .PP Creates a lock on the \fCmutex\fP\&. .PP To unlock the \fCmutex\fP, call \fBwget_thread_mutex_unlock()\fP\&. .SS "void wget_thread_mutex_unlock (wget_thread_mutex_t mutex)" .PP \fBParameters\fP .RS 4 \fImutex\fP The mutex to be unlocked .RE .PP Unlocks the \fCmutex\fP\&. .SS "int wget_thread_cond_init (wget_thread_cond_t * cond)" .PP \fBParameters\fP .RS 4 \fIcond\fP The conditional to initialize .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Initializes the conditional \fCcond\fP\&. .PP After usage, a call to \fBwget_thread_cond_destroy()\fP frees the allocated resources\&. .SS "int wget_thread_cond_destroy (wget_thread_cond_t * cond)" .PP \fBParameters\fP .RS 4 \fIcond\fP The conditional to destroy .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Free's the conditional \fCcond\fP and it's resources\&. .PP After calling this function, \fCcond\fP cannot be used any more\&. .SS "int wget_thread_cond_signal (wget_thread_cond_t cond)" .PP \fBParameters\fP .RS 4 \fIcond\fP The conditional to signal a condition .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Wakes up one (random) thread that waits on the conditional\&. .SS "int wget_thread_cond_wait (wget_thread_cond_t cond, wget_thread_mutex_t mutex, long long ms)" .PP \fBParameters\fP .RS 4 \fIcond\fP The conditional to wait for .br \fImutex\fP The mutex needed for thread-safety .br \fIms\fP The wait timeout in milliseconds .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Waits for a condition with a max\&. timeout of \fCms\fP milliseconds\&. .PP To wait forever use a timeout lower or equal then 0\&. .SS "int wget_thread_start (wget_thread_t * thread, void *(*)(void *) start_routine, void * arg, G_GNUC_WGET_UNUSED int flags)" .PP \fBParameters\fP .RS 4 \fIthread\fP The thread variable to be initialized .br \fIstart_routine\fP The thread function to start .br \fIarg\fP The argument given to \fCstart_routine\fP .br \fIflags\fP Currently unused .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Start \fCstart_routine\fP as own thread with argument \fCarg\fP\&. .SS "int wget_thread_cancel (G_GNUC_WGET_UNUSED wget_thread_t thread)" .PP \fBParameters\fP .RS 4 \fIthread\fP Thread to cancel .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Currently a no-op function, since it's not portable\&. .SS "int wget_thread_kill (G_GNUC_WGET_UNUSED wget_thread_t thread, G_GNUC_WGET_UNUSED int sig)" .PP \fBParameters\fP .RS 4 \fIthread\fP Thread to send the signal to .br \fIsig\fP Signal to send .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Currently a no-op function, since it's not portable\&. .SS "int wget_thread_join (wget_thread_t * thread)" .PP \fBParameters\fP .RS 4 \fIthread\fP Thread to wait for .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure .RE .PP Wait until the \fCthread\fP has been stopped\&. .PP This function just waits - to stop a thread you have take your own measurements\&. .SS "wget_thread_id_t wget_thread_self (void)" .PP \fBReturns\fP .RS 4 The thread id of the caller\&. .RE .PP .SS "bool wget_thread_support (void)" .PP \fBReturns\fP .RS 4 Whether libwget supports multi-threading on this platform or not\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for wget2 from the source code\&.