rllib  1
rlwthread.h
Go to the documentation of this file.
1 /***************************************************************************
2  wthread.h - description
3  -------------------
4  begin : Sun Jan 02 2000
5  copyright : (C) 2001 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 /***********************************************************************************
17 
18 Wrapper for posix threads (UNIX,VMS,windows)
19 
20 (C) R. Lehrig 2001 lehrig@t-online.de
21 
22 ***********************************************************************************/
23 
24 #ifndef _RL_WTHREAD_H_
25 #define _RL_WTHREAD_H_
26 
27 #ifndef SWIG
28 
29 #include "rldefine.h"
30 
31 #ifdef RLWIN32
32 #define WTREAD_GNUC10 ( __GNUC__ * 1000 ) + __GNUC_MINOR__
33 #if WTREAD_GNUC10 < 4008
34 #define RLWIN32THREAD
35 #else
36 #include <pthread.h>
37 #endif
38 #endif
39 
40 #ifdef RLWIN32THREAD
41 
42 #include <windows.h>
43 #include <winbase.h>
44 #include <stddef.h>
45 #include <string.h>
46 
47 #ifndef _WRAPTHREAD_
48 #ifndef _WTHREAD_H_
49 typedef unsigned long int pthread_t;
50 
51 /* Attributes for threads */
52 typedef struct __sched_param
53 {
56 
57 typedef struct
58 {
61  struct __sched_param __schedparam;
63  int __scope;
64  size_t __guardsize;
66  void *__stackaddr;
67  size_t __stacksize;
69 
70 typedef HANDLE pthread_mutex_t;
71 //old typedef CRITICAL_SECTION pthread_mutex_t;
72 typedef long pthread_mutexattr_t;
73 #endif
74 #endif
75 
76 #else /* VMS or UNIX or new GCC on Windows*/
77 #ifndef WIN_PTHREADS_H
78 #include <pthread.h>
79 #endif
80 #endif /* end of MSWINDOWS */
81 
82 #ifndef _WRAPTHREAD_
83 #ifndef _WTHREAD_H_
84 typedef struct
85 {
86 #ifdef RLWIN32THREAD
87  int cmax;
88  HANDLE hSemaphore;
89 #else
90  int cmax;
91  int nready;
92  pthread_mutex_t mutex;
93  pthread_cond_t cond;
94 #endif
95 }WSEMAPHORE;
96 #endif
97 #endif
98 
99 /* function prototypes */
100 //#ifdef __cplusplus
101 //extern "C" {
102 //#endif
104 int rlwthread_create(pthread_t *tid, const pthread_attr_t *attr,
105  void *(*func)(void*), void *arg);
107 void rlwthread_exit(void *status);
108 int rlwthread_join(pthread_t tid, void **status);
114 int rlwthread_cancel(pthread_t tid);
115 int rlwrapinit_semaphore(WSEMAPHORE *s, int cmax);
119 int rlwthread_sleep(long msec);
120 void rlsleep(long msec);
121 //#ifdef __cplusplus
122 //};
123 //#endif
124 
125 #else
126 // SWIG
127 void rlsleep(long msec);
128 #endif
129 
130 #endif
void rlwthread_exit(void *status)
Definition: rlwthread.cpp:94
int rlwrapwait_semaphore(WSEMAPHORE *s)
Definition: rlwthread.cpp:341
int rlwthread_attr_init(pthread_attr_t *attr)
Definition: rlwthread.cpp:36
HANDLE hSemaphore
Definition: rlwthread.h:88
struct __sched_param SCHED_PARAM
int rlwthread_sleep(long msec)
Definition: rlwthread.cpp:366
int rlwthread_mutex_init(pthread_mutex_t *mptr, const pthread_mutexattr_t *attr)
Definition: rlwthread.cpp:160
int rlwthread_join(pthread_t tid, void **status)
Definition: rlwthread.cpp:113
size_t __stacksize
Definition: rlwthread.h:67
size_t __guardsize
Definition: rlwthread.h:64
int rlwthread_mutex_destroy(pthread_mutex_t *mptr)
Definition: rlwthread.cpp:178
int cmax
Definition: rlwthread.h:87
int rlwthread_mutex_lock(pthread_mutex_t *mptr)
Definition: rlwthread.cpp:193
int rlwrapincrement_semaphore(WSEMAPHORE *s)
Definition: rlwthread.cpp:310
int __schedpolicy
Definition: rlwthread.h:60
int rlwthread_cancel(pthread_t tid)
Definition: rlwthread.cpp:253
void * __stackaddr
Definition: rlwthread.h:66
int __inheritsched
Definition: rlwthread.h:62
int rlwrapinit_semaphore(WSEMAPHORE *s, int cmax)
Definition: rlwthread.cpp:268
HANDLE pthread_mutex_t
Definition: rlwthread.h:70
int rlwthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(*func)(void *), void *arg)
Definition: rlwthread.cpp:54
int sched_priority
Definition: rlwthread.h:54
unsigned long int pthread_t
Definition: rlwthread.h:49
int rlwthread_mutex_trylock(pthread_mutex_t *mptr)
Definition: rlwthread.cpp:215
void rlsleep(long msec)
Definition: rlwthread.cpp:396
int rlwthread_mutex_unlock(pthread_mutex_t *mptr)
Definition: rlwthread.cpp:238
int rlwrapdestroy_semaphore(WSEMAPHORE *s)
Definition: rlwthread.cpp:294
int __stackaddr_set
Definition: rlwthread.h:65
long pthread_mutexattr_t
Definition: rlwthread.h:72
void rlwthread_close_handle(pthread_t *tid)
Definition: rlwthread.cpp:79
int __detachstate
Definition: rlwthread.h:59