00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _WTHREAD_H_
00026 #define _WTHREAD_H_
00027
00028 #ifdef _WIN32
00029
00030 #include <windows.h>
00031 #include <winbase.h>
00032 #include <stddef.h>
00033 #include <string.h>
00034
00035 #ifndef _WRAPTHREAD_
00036 #ifndef _RL_WTHREAD_H_
00037 typedef unsigned long int pthread_t;
00038
00039
00040 struct __sched_param
00041 {
00042 int sched_priority;
00043 };
00044
00045 typedef struct
00046 {
00047 int __detachstate;
00048 int __schedpolicy;
00049 struct __sched_param __schedparam;
00050 int __inheritsched;
00051 int __scope;
00052 size_t __guardsize;
00053 int __stackaddr_set;
00054 void *__stackaddr;
00055 size_t __stacksize;
00056 }pthread_attr_t;
00057
00058 typedef HANDLE pthread_mutex_t;
00059
00060 typedef long pthread_mutexattr_t;
00061 #endif
00062 #endif
00063
00064 #else
00065 #include <pthread.h>
00066 #endif
00067
00068 #ifndef _WRAPTHREAD_
00069 #ifndef _RL_WTHREAD_H_
00070 typedef struct
00071 {
00072 #ifdef _WIN32
00073 int cmax;
00074 HANDLE hSemaphore;
00075 #else
00076 int cmax;
00077 int nready;
00078 pthread_mutex_t mutex;
00079 pthread_cond_t cond;
00080 #endif
00081 }WSEMAPHORE;
00082 #endif
00083 #endif
00084
00085
00086 #ifndef __VMS
00087 #ifdef __cplusplus
00088 extern "C" {
00089 #endif
00090 #endif
00091 int pvthread_attr_init(pthread_attr_t *attr);
00092 int pvthread_create(pthread_t *tid, const pthread_attr_t *attr,
00093 void *(*func)(void*), void *arg);
00094 void pvthread_close_handle(pthread_t *tid);
00095 void pvthread_exit(void *status);
00096 int pvthread_join(pthread_t tid, void **status);
00097 int pvthread_mutex_init(pthread_mutex_t *mptr, const pthread_mutexattr_t *attr);
00098 int pvthread_mutex_destroy(pthread_mutex_t *mptr);
00099 int pvthread_mutex_lock(pthread_mutex_t *mptr);
00100 int pvthread_mutex_trylock(pthread_mutex_t *mptr);
00101 int pvthread_mutex_unlock(pthread_mutex_t *mptr);
00102 int pvthread_cancel(pthread_t tid);
00103 int pvinit_semaphore(WSEMAPHORE *s, int cmax);
00104 int pvincrement_semaphore(WSEMAPHORE *s);
00105 int pvwait_semaphore(WSEMAPHORE *s);
00106 int pvthread_sleep(long msec);
00107 #ifndef __VMS
00108 #ifdef __cplusplus
00109 };
00110 #endif
00111 #endif
00112
00113 #endif