rllib  1
rlthread.h
Go to the documentation of this file.
1 /***************************************************************************
2  rlthread.h - description
3  -------------------
4  begin : Tue Jan 02 2001
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 #ifndef _RL_THREAD_H_
17 #define _RL_THREAD_H_
18 
19 #include "rldefine.h"
20 #include "rlwthread.h"
21 
22 class rlThread;
23 
27 typedef struct
28 {
30  void *user;
31  int running;
32 }
34 
38 class rlThread
39 {
40 public:
41  rlThread(int max_semphore=1000);
42  virtual ~rlThread();
63  int create(void *(*func)(void*), void *argument);
64 
70  int trylock();
71 
75  int lock();
76 
80  int unlock();
81 
85  int waitSemaphore();
86 
90  int incrementSemaphore();
91 
95  int join(void **status);
96 
100  int cancel();
101 
105  void threadExit(void *status);
106 
111 private:
113 };
114 
118 class rlMutex
119 {
120 public:
121  //rlMutex(const pthread_mutexattr_t *attr = NULL);
122  rlMutex(const void *attr = NULL);
123  virtual ~rlMutex();
124 
130  int trylock();
131 
135  int lock();
136 
140  int unlock();
141 
143 };
144 
149 {
150 public:
151  rlSemaphore(int max_semaphore = 1000);
152  virtual ~rlSemaphore();
153 
157  int waitSemaphore();
158 
162  int incrementSemaphore();
163 
165 };
166 
167 #endif
int trylock()
Definition: rlthread.cpp:42
THREAD_PARAM arg
Definition: rlthread.h:112
int join(void **status)
Definition: rlthread.cpp:73
WSEMAPHORE semaphore
Definition: rlthread.h:164
pthread_attr_t attr
Definition: rlthread.h:108
int cancel()
Definition: rlthread.cpp:78
void * user
Definition: rlthread.h:30
void threadExit(void *status)
Definition: rlthread.cpp:67
rlThread * thread
Definition: rlthread.h:29
int lock()
Definition: rlthread.cpp:105
int waitSemaphore()
Definition: rlthread.cpp:57
int unlock()
Definition: rlthread.cpp:52
virtual ~rlThread()
Definition: rlthread.cpp:28
int create(void *(*func)(void *), void *argument)
Definition: rlthread.cpp:35
virtual ~rlMutex()
Definition: rlthread.cpp:95
rlSemaphore(int max_semaphore=1000)
Definition: rlthread.cpp:116
HANDLE pthread_mutex_t
Definition: rlwthread.h:70
unsigned long int pthread_t
Definition: rlwthread.h:49
virtual ~rlSemaphore()
Definition: rlthread.cpp:121
rlMutex(const void *attr=NULL)
Definition: rlthread.cpp:90
int unlock()
Definition: rlthread.cpp:110
int incrementSemaphore()
Definition: rlthread.cpp:62
pthread_mutex_t mutex
Definition: rlthread.h:142
rlThread(int max_semphore=1000)
Definition: rlthread.cpp:18
int incrementSemaphore()
Definition: rlthread.cpp:131
int waitSemaphore()
Definition: rlthread.cpp:126
pthread_t tid
Definition: rlthread.h:107
int trylock()
Definition: rlthread.cpp:100
int lock()
Definition: rlthread.cpp:47
WSEMAPHORE semaphore
Definition: rlthread.h:110
pthread_mutex_t mutex
Definition: rlthread.h:109
int running
Definition: rlthread.h:31