📄 pthread.h
字号:
PTW32_DLLPORT int pthread_detach (pthread_t tid);PTW32_DLLPORT int pthread_equal (pthread_t t1, pthread_t t2);PTW32_DLLPORT void pthread_exit (void *value_ptr);PTW32_DLLPORT int pthread_join (pthread_t thread, void **value_ptr);PTW32_DLLPORT pthread_t pthread_self (void);PTW32_DLLPORT int pthread_cancel (pthread_t thread);PTW32_DLLPORT int pthread_setcancelstate (int state, int *oldstate);PTW32_DLLPORT int pthread_setcanceltype (int type, int *oldtype);PTW32_DLLPORT void pthread_testcancel (void);PTW32_DLLPORT int pthread_once (pthread_once_t * once_control, void (*init_routine) (void));#if PTW32_LEVEL >= PTW32_LEVEL_MAXPTW32_DLLPORT ptw32_cleanup_t *ptw32_pop_cleanup (int execute);PTW32_DLLPORT void ptw32_push_cleanup (ptw32_cleanup_t * cleanup, void (*routine) (void *), void *arg);#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX *//* * Thread Specific Data Functions */PTW32_DLLPORT int pthread_key_create (pthread_key_t * key, void (*destructor) (void *));PTW32_DLLPORT int pthread_key_delete (pthread_key_t key);PTW32_DLLPORT int pthread_setspecific (pthread_key_t key, const void *value);PTW32_DLLPORT void *pthread_getspecific (pthread_key_t key);/* * Mutex Attribute Functions */PTW32_DLLPORT int pthread_mutexattr_init (pthread_mutexattr_t * attr);PTW32_DLLPORT int pthread_mutexattr_destroy (pthread_mutexattr_t * attr);PTW32_DLLPORT int pthread_mutexattr_getpshared (const pthread_mutexattr_t * attr, int *pshared);PTW32_DLLPORT int pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, int pshared);PTW32_DLLPORT int pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind);PTW32_DLLPORT int pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind);/* * Barrier Attribute Functions */PTW32_DLLPORT int pthread_barrierattr_init (pthread_barrierattr_t * attr);PTW32_DLLPORT int pthread_barrierattr_destroy (pthread_barrierattr_t * attr);PTW32_DLLPORT int pthread_barrierattr_getpshared (const pthread_barrierattr_t * attr, int *pshared);PTW32_DLLPORT int pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, int pshared);/* * Mutex Functions */PTW32_DLLPORT int pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr);PTW32_DLLPORT int pthread_mutex_destroy (pthread_mutex_t * mutex);PTW32_DLLPORT int pthread_mutex_lock (pthread_mutex_t * mutex);PTW32_DLLPORT int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime);PTW32_DLLPORT int pthread_mutex_trylock (pthread_mutex_t * mutex);PTW32_DLLPORT int pthread_mutex_unlock (pthread_mutex_t * mutex);/* * Spinlock Functions */PTW32_DLLPORT int pthread_spin_init (pthread_spinlock_t * lock, int pshared);PTW32_DLLPORT int pthread_spin_destroy (pthread_spinlock_t * lock);PTW32_DLLPORT int pthread_spin_lock (pthread_spinlock_t * lock);PTW32_DLLPORT int pthread_spin_trylock (pthread_spinlock_t * lock);PTW32_DLLPORT int pthread_spin_unlock (pthread_spinlock_t * lock);/* * Barrier Functions */PTW32_DLLPORT int pthread_barrier_init (pthread_barrier_t * barrier, const pthread_barrierattr_t * attr, unsigned int count);PTW32_DLLPORT int pthread_barrier_destroy (pthread_barrier_t * barrier);PTW32_DLLPORT int pthread_barrier_wait (pthread_barrier_t * barrier);/* * Condition Variable Attribute Functions */PTW32_DLLPORT int pthread_condattr_init (pthread_condattr_t * attr);PTW32_DLLPORT int pthread_condattr_destroy (pthread_condattr_t * attr);PTW32_DLLPORT int pthread_condattr_getpshared (const pthread_condattr_t * attr, int *pshared);PTW32_DLLPORT int pthread_condattr_setpshared (pthread_condattr_t * attr, int pshared);/* * Condition Variable Functions */PTW32_DLLPORT int pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr);PTW32_DLLPORT int pthread_cond_destroy (pthread_cond_t * cond);PTW32_DLLPORT int pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex);PTW32_DLLPORT int pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex, const struct timespec *abstime);PTW32_DLLPORT int pthread_cond_signal (pthread_cond_t * cond);PTW32_DLLPORT int pthread_cond_broadcast (pthread_cond_t * cond);/* * Scheduling */PTW32_DLLPORT int pthread_setschedparam (pthread_t thread, int policy, const struct sched_param *param);PTW32_DLLPORT int pthread_getschedparam (pthread_t thread, int *policy, struct sched_param *param);PTW32_DLLPORT int pthread_setconcurrency (int); PTW32_DLLPORT int pthread_getconcurrency (void);/* * Read-Write Lock Functions */PTW32_DLLPORT int pthread_rwlock_init(pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr);PTW32_DLLPORT int pthread_rwlock_destroy(pthread_rwlock_t *lock);PTW32_DLLPORT int pthread_rwlock_tryrdlock(pthread_rwlock_t *);PTW32_DLLPORT int pthread_rwlock_trywrlock(pthread_rwlock_t *);PTW32_DLLPORT int pthread_rwlock_rdlock(pthread_rwlock_t *lock);PTW32_DLLPORT int pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, const struct timespec *abstime);PTW32_DLLPORT int pthread_rwlock_wrlock(pthread_rwlock_t *lock);PTW32_DLLPORT int pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, const struct timespec *abstime);PTW32_DLLPORT int pthread_rwlock_unlock(pthread_rwlock_t *lock);PTW32_DLLPORT int pthread_rwlockattr_init (pthread_rwlockattr_t * attr);PTW32_DLLPORT int pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr);PTW32_DLLPORT int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, int *pshared);PTW32_DLLPORT int pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, int pshared);#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1/* * Signal Functions. Should be defined in <signal.h> but MSVC and MinGW32 * already have signal.h that don't define these. */PTW32_DLLPORT int pthread_kill(pthread_t thread, int sig);/* * Non-portable functions *//* * Compatibility with Linux. */PTW32_DLLPORT int pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, int kind);PTW32_DLLPORT int pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, int *kind);/* * Possibly supported by other POSIX threads implementations */PTW32_DLLPORT int pthread_delay_np (struct timespec * interval);PTW32_DLLPORT int pthread_num_processors_np(void);/* * Useful if an application wants to statically link * the lib rather than load the DLL at run-time. */PTW32_DLLPORT int pthread_win32_process_attach_np(void);PTW32_DLLPORT int pthread_win32_process_detach_np(void);PTW32_DLLPORT int pthread_win32_thread_attach_np(void);PTW32_DLLPORT int pthread_win32_thread_detach_np(void);/* * Register a system time change with the library. * Causes the library to perform various functions * in response to the change. Should be called whenever * the application's top level window receives a * WM_TIMECHANGE message. It can be passed directly to * pthread_create() as a new thread if desired. */PTW32_DLLPORT void * pthread_timechange_handler_np(void *);#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */#if PTW32_LEVEL >= PTW32_LEVEL_MAX/* * Returns the Win32 HANDLE for the POSIX thread. */PTW32_DLLPORT HANDLE pthread_getw32threadhandle_np(pthread_t thread);/* * Protected Methods * * This function blocks until the given WIN32 handle * is signaled or pthread_cancel had been called. * This function allows the caller to hook into the * PThreads cancel mechanism. It is implemented using * * WaitForMultipleObjects * * on 'waitHandle' and a manually reset WIN32 Event * used to implement pthread_cancel. The 'timeout' * argument to TimedWait is simply passed to * WaitForMultipleObjects. */PTW32_DLLPORT int pthreadCancelableWait (HANDLE waitHandle);PTW32_DLLPORT int pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout);#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX *//* * Thread-Safe C Runtime Library Mappings. */#ifndef _UWIN# if defined(NEED_ERRNO) PTW32_DLLPORT int * _errno( void );# else# ifndef errno# if (defined(_MT) || defined(_DLL)) __declspec(dllimport) extern int * __cdecl _errno(void);# define errno (*_errno())# endif# endif# endif#endif/* * WIN32 C runtime library had been made thread-safe * without affecting the user interface. Provide * mappings from the UNIX thread-safe versions to * the standard C runtime library calls. * Only provide function mappings for functions that * actually exist on WIN32. */#if !defined(__MINGW32__)#define strtok_r( _s, _sep, _lasts ) \ ( *(_lasts) = strtok( (_s), (_sep) ) )#endif /* !__MINGW32__ */#define asctime_r( _tm, _buf ) \ ( strcpy( (_buf), asctime( (_tm) ) ), \ (_buf) )#define ctime_r( _clock, _buf ) \ ( strcpy( (_buf), ctime( (_clock) ) ), \ (_buf) )#define gmtime_r( _clock, _result ) \ ( *(_result) = *gmtime( (_clock) ), \ (_result) )#define localtime_r( _clock, _result ) \ ( *(_result) = *localtime( (_clock) ), \ (_result) )#define rand_r( _seed ) \ ( _seed == _seed? rand() : rand() )#ifdef __cplusplus/* * Internal exceptions */class ptw32_exception {};class ptw32_exception_cancel : public ptw32_exception {};class ptw32_exception_exit : public ptw32_exception {};#endif#if PTW32_LEVEL >= PTW32_LEVEL_MAX/* FIXME: This is only required if the library was built using SEH *//* * Get internal SEH tag */PTW32_DLLPORT DWORD ptw32_get_exception_services_code(void);#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */#ifndef PTW32_BUILD#ifdef __CLEANUP_SEH/* * Redefine the SEH __except keyword to ensure that applications * propagate our internal exceptions up to the library's internal handlers. */#define __except( E ) \ __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \ ? EXCEPTION_CONTINUE_SEARCH : ( E ) )#endif /* __CLEANUP_SEH */#ifdef __CLEANUP_CXX/* * Redefine the C++ catch keyword to ensure that applications * propagate our internal exceptions up to the library's internal handlers. */#ifdef _MSC_VER /* * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' * if you want Pthread-Win32 cancelation and pthread_exit to work. */#ifndef PtW32NoCatchWarn#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.")#pragma message("------------------------------------------------------------------")#pragma message("When compiling applications with MSVC++ and C++ exception handling:")#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads")#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread")#pragma message(" cancelation and pthread_exit to work. For example:")#pragma message("")#pragma message(" #ifdef PtW32CatchAll")#pragma message(" PtW32CatchAll")#pragma message(" #else")#pragma message(" catch(...)")#pragma message(" #endif")#pragma message(" {")#pragma message(" /* Catchall block processing */")#pragma message(" }")#pragma message("------------------------------------------------------------------")#endif#define PtW32CatchAll \ catch( ptw32_exception & ) { throw; } \ catch( ... )#else /* _MSC_VER */#define catch( E ) \ catch( ptw32_exception & ) { throw; } \ catch( E )#endif /* _MSC_VER */#endif /* __CLEANUP_CXX */#endif /* ! PTW32_BUILD */#ifdef __cplusplus} /* End of extern "C" */#endif /* __cplusplus */#ifdef PTW32__HANDLE_DEF# undef HANDLE#endif#ifdef PTW32__DWORD_DEF# undef DWORD#endif#undef PTW32_LEVEL#undef PTW32_LEVEL_MAX#endif /* PTHREAD_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -