📄 ithread.h
字号:
* pthread_rwlockattr_t) * int *kind (one of ITHREAD_PROCESS_PRIVATE or ITHREAD_PROCESS_SHARED) * * Returns: * 0 on success. Nonzero on failure. * Always returns 0. * See man page for pthread_rwlockatttr_getpshared *****************************************************************************/#define ithread_rwlockatttr_getpshared pthread_rwlockatttr_getpshared /**************************************************************************** * Function: ithread_rwlock_init * * Description: * Initializes rwlock. * Must be called before use. * * Parameters: * ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t) * const ithread_rwlockattr_t * rwlock_attr * Returns: * 0 on success, Nonzero on failure. * Always returns 0. * See man page for pthread_rwlock_init *****************************************************************************/#define ithread_rwlock_init pthread_rwlock_init/**************************************************************************** * Function: ithread_rwlock_rdlock * * Description: * Locks rwlock for reading. * Parameters: * ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t) * rwlock must be initialized. * * Returns: * 0 on success, Nonzero on failure. * Always returns 0. * See man page for pthread_rwlock_rdlock *****************************************************************************/#define ithread_rwlock_rdlock pthread_rwlock_rdlock/**************************************************************************** * Function: ithread_rwlock_wrlock * * Description: * Locks rwlock for writting. * Parameters: * ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t) * rwlock must be initialized. * * Returns: * 0 on success, Nonzero on failure. * Always returns 0. * See man page for pthread_rwlock_wrlock *****************************************************************************/#define ithread_rwlock_wrlock pthread_rwlock_wrlock/**************************************************************************** * Function: ithread_rwlock_unlock * * Description: * Unlocks rwlock. * * Parameters: * ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t) * rwlock must be initialized. * * Returns: * 0 on success, Nonzero on failure. * Always returns 0. * See man page for pthread_rwlock_unlock *****************************************************************************/#define ithread_rwlock_unlock pthread_rwlock_unlock/**************************************************************************** * Function: ithread_rwlock_destroy * * Description: * Releases any resources held by the rwlock. * rwlock can no longer be used after this call. * rwlock is only destroyed when there are no longer any threads waiting on it. * rwlock cannot be destroyed if it is locked. * Parameters: * ithread_rwlock_t * rwlock (must be valid non NULL pointer to pthread_rwlock_t) * rwlock must be initialized. * Returns: * 0 on success. Nonzero on failure. * Always returns 0. * See man page for pthread_rwlock_destroy *****************************************************************************/#define ithread_rwlock_destroy pthread_rwlock_destroy/**************************************************************************** * Function: ithread_cond_init * * Description: * Initializes condition variable. * Must be called before use. * Parameters: * ithread_cond_t * cond (must be valid non NULL pointer to pthread_cond_t) * const ithread_condattr_t * cond_attr (ignored) * Returns: * 0 on success, Nonzero on failure. * See man page for pthread_cond_init *****************************************************************************/#define ithread_cond_init pthread_cond_init/**************************************************************************** * Function: ithread_cond_signal * * Description: * Wakes up exactly one thread waiting on condition. * Associated mutex MUST be locked by thread before entering this call. * Parameters: * ithread_cond_t * cond (must be valid non NULL pointer to * ithread_cond_t) * cond must be initialized * Returns: * 0 on success, Nonzero on failure. * See man page for pthread_cond_signal *****************************************************************************/#define ithread_cond_signal pthread_cond_signal/**************************************************************************** * Function: ithread_cond_broadcast * * Description: * Wakes up all threads waiting on condition. * Associated mutex MUST be locked by thread before entering this call. * Parameters: * ithread_cond_t * cond (must be valid non NULL pointer to * ithread_cond_t) * cond must be initialized * Returns: * 0 on success, Nonzero on failure. * See man page for pthread_cond_broadcast *****************************************************************************/#define ithread_cond_broadcast pthread_cond_broadcast /**************************************************************************** * Function: ithread_cond_wait * * Description: * Atomically releases mutex and waits on condition. * Associated mutex MUST be locked by thread before entering this call. * Mutex is reacquired when call returns. * Parameters: * ithread_cond_t * cond (must be valid non NULL pointer to * ithread_cond_t) * cond must be initialized * ithread_mutex_t *mutex (must be valid non NULL pointer to * ithread_mutex_t) * Mutex must be locked. * Returns: * 0 on success, Nonzero on failure. * See man page for pthread_cond_wait *****************************************************************************/#define ithread_cond_wait pthread_cond_wait /**************************************************************************** * Function: pthread_cond_timedwait * * Description: * Atomically releases the associated mutex and waits on the condition. * If the condition is not signaled in the specified time * than the * call times out and returns. * Associated mutex MUST be locked by thread before entering * this call. * Mutex is reacquired when call returns. * Parameters: * ithread_cond_t * cond (must be valid non NULL pointer to * ithread_cond_t) * cond must be initialized * ithread_mutex_t *mutex (must be valid non NULL pointer to * ithread_mutex_t) * Mutex must be locked. * const struct timespec *abstime (absolute time, measured * from Jan 1, 1970) * Returns: * 0 on success. ETIMEDOUT on timeout. Nonzero on failure. * See man page for pthread_cond_timedwait ***************************************************************************/ #define ithread_cond_timedwait pthread_cond_timedwait /**************************************************************************** * Function: ithread_cond_destroy * * Description: * Releases any resources held by the condition variable. * Condition variable can no longer be used after this call. * Parameters: * ithread_cond_t * cond (must be valid non NULL pointer to * ithread_cond_t) * cond must be initialized. * Returns: * 0 on success. Nonzero on failure. * See man page for pthread_cond_destroy ***************************************************************************/#define ithread_cond_destroy pthread_cond_destroy /**************************************************************************** * Function: ithread_create * * Description: * Creates a thread with the given start routine * and argument. * Parameters: * ithread_t * thread (must be valid non NULL pointer to pthread_t) * ithread_attr_t *attr, IGNORED * void * (start_routine) (void *arg) (start routine) * void * arg - argument. * Returns: * 0 on success. Nonzero on failure. * Returns EAGAIN if a new thread can not be created. * Returns EINVAL if there is a problem with the arguments. * See man page fore pthread_create ***************************************************************************/#define ithread_create pthread_create /**************************************************************************** * Function: ithread_cancel * * Description: * Cancels a thread. * Parameters: * ithread_t * thread (must be valid non NULL pointer to ithread_t) * Returns: * 0 on success. Nonzero on failure. * See man page for pthread_cancel ***************************************************************************/#define ithread_cancel pthread_cancel /**************************************************************************** * Function: ithread_exit * * Description: * Returns a return code from a thread. * Implicitly called when the start routine returns. * Parameters: * void * return_code return code to return * See man page for pthread_exit ***************************************************************************/#define ithread_exit pthread_exit/**************************************************************************** * Function: ithread_get_current_thread_id * * Description: * Returns the handle of the currently running thread. * Returns: * The handle of the currently running thread. * See man page for pthread_self ***************************************************************************/#define ithread_get_current_thread_id pthread_self /**************************************************************************** * Function: ithread_self * * Description: * Returns the handle of the currently running thread. * Returns: * The handle of the currently running thread. * See man page for pthread_self ***************************************************************************/#define ithread_self pthread_self /**************************************************************************** * Function: ithread_detach * * Description: * Makes a thread's resources reclaimed immediately * after it finishes * execution. * Returns: * 0 on success, Nonzero on failure. * See man page for pthread_detach ***************************************************************************/#define ithread_detach pthread_detach /**************************************************************************** * Function: ithread_join * * Description: * Suspends the currently running thread until the * specified thread * has finished. * Returns the return code of the thread, or ITHREAD_CANCELED * if the thread has been canceled. * Parameters: * ithread_t *thread (valid non null thread identifier) * void ** return (space for return code) * Returns: * 0 on success, Nonzero on failure. * See man page for pthread_join ***************************************************************************/#define ithread_join pthread_join /**************************************************************************** * Function: isleep * * Description: * Suspends the currently running thread for the specified number * of seconds * Always returns 0. * Parameters: * unsigned int seconds - number of seconds to sleep. * Returns: * 0 on success, Nonzero on failure. * See man page for sleep (man 3 sleep) *****************************************************************************/#ifndef WIN32#define isleep sleep#else#define isleep(x) Sleep((x)*1000)#endif/**************************************************************************** * Function: isleep * * Description: * Suspends the currently running thread for the specified number * of milliseconds * Always returns 0. * Parameters: * unsigned int milliseconds - number of milliseconds to sleep. * Returns: * 0 on success, Nonzero on failure. * See man page for sleep (man 3 sleep) *****************************************************************************/#ifndef WIN32#define imillisleep(x) usleep(1000*x)#else#define imillisleep Sleep#endif#ifdef WIN32 #ifndef UPNP_STATIC_LIB #ifdef LIBUPNP_EXPORTS /* set up declspec for dll export to make functions visible to library users */ #define EXPORT_SPEC __declspec(dllexport) #else #define EXPORT_SPEC __declspec(dllimport) #endif #else #define EXPORT_SPEC #endif#else #define EXPORT_SPEC#endif#ifndef PTHREAD_MUTEX_RECURSIVE/* NK: Added for satisfying the gcc compiler */EXPORT_SPEC int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind);#endif#ifdef __cplusplus}#endif#endif /* ITHREADH */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -