rllib  1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
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 
33 #include <windows.h>
34 #include <winbase.h>
35 #include <stddef.h>
36 #include <string.h>
37 
38 #ifndef _WRAPTHREAD_
39 #ifndef _WTHREAD_H_
40 typedef unsigned long int pthread_t;
41 
42 /* Attributes for threads */
43 typedef struct __sched_param
44 {
47 
48 typedef struct
49 {
52  struct __sched_param __schedparam;
54  int __scope;
55  size_t __guardsize;
57  void *__stackaddr;
58  size_t __stacksize;
60 
61 typedef HANDLE pthread_mutex_t;
62 //old typedef CRITICAL_SECTION pthread_mutex_t;
63 typedef long pthread_mutexattr_t;
64 #endif
65 #endif
66 
67 #else /* VMS or UNIX */
68 #include <pthread.h>
69 #endif /* end of MSWINDOWS */
70 
71 #ifndef _WRAPTHREAD_
72 #ifndef _WTHREAD_H_
73 typedef struct
74 {
75 #ifdef RLWIN32
76  int cmax;
77  HANDLE hSemaphore;
78 #else
79  int cmax;
80  int nready;
81  pthread_mutex_t mutex;
82  pthread_cond_t cond;
83 #endif
84 }WSEMAPHORE;
85 #endif
86 #endif
87 
88 /* function prototypes */
89 //#ifdef __cplusplus
90 //extern "C" {
91 //#endif
93 int rlwthread_create(pthread_t *tid, const pthread_attr_t *attr,
94  void *(*func)(void*), void *arg);
96 void rlwthread_exit(void *status);
97 int rlwthread_join(pthread_t tid, void **status);
103 int rlwthread_cancel(pthread_t tid);
104 int rlwrapinit_semaphore(WSEMAPHORE *s, int cmax);
108 int rlwthread_sleep(long msec);
109 void rlsleep(long msec);
110 //#ifdef __cplusplus
111 //};
112 //#endif
113 
114 #else
115 // SWIG
116 void rlsleep(long msec);
117 #endif
118 
119 #endif