rllib  1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
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  virtual ~rlMutex();
123 
129  int trylock();
130 
134  int lock();
135 
139  int unlock();
140 
142 };
143 
148 {
149 public:
150  rlSemaphore(int max_semaphore = 1000);
151  virtual ~rlSemaphore();
152 
156  int waitSemaphore();
157 
161  int incrementSemaphore();
162 
164 };
165 
166 #endif