Rev 270 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 270 | Rev 800 | ||
|---|---|---|---|
| 1 | /*************************************************************************** |
1 | /*************************************************************************** |
| 2 | rlthread.h - description |
2 | rlthread.h - description |
| 3 | ------------------- |
3 | ------------------- |
| 4 | begin : Tue Jan 02 2001 |
4 | begin : Tue Jan 02 2001 |
| 5 | copyright : (C) 2001 by Rainer Lehrig |
5 | copyright : (C) 2001 by Rainer Lehrig |
| 6 | email : lehrig@t-online.de |
6 | email : lehrig@t-online.de |
| 7 | ***************************************************************************/ |
7 | ***************************************************************************/ |
| 8 | 8 | ||
| 9 | /*************************************************************************** |
9 | /*************************************************************************** |
| 10 | * * |
10 | * * |
| 11 | * This library is free software; you can redistribute it and/or modify * |
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 * |
12 | * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as * |
| 13 | * published by the Free Software Foundation * |
13 | * published by the Free Software Foundation * |
| 14 | * * |
14 | * * |
| 15 | ***************************************************************************/ |
15 | ***************************************************************************/ |
| 16 | #ifndef _RL_THREAD_H_ |
16 | #ifndef _RL_THREAD_H_ |
| 17 | #define _RL_THREAD_H_ |
17 | #define _RL_THREAD_H_ |
| 18 | 18 | ||
| 19 | #include "rldefine.h" |
19 | #include "rldefine.h" |
| 20 | #include "rlwthread.h" |
20 | #include "rlwthread.h" |
| 21 | 21 | ||
| 22 | class rlThread; |
22 | class rlThread; |
| 23 | 23 | ||
| 24 | typedef struct |
24 | typedef struct |
| 25 | { |
25 | { |
| 26 | rlThread *thread; |
26 | rlThread *thread; |
| 27 | void *user; |
27 | void *user; |
| 28 | int running; |
28 | int running; |
| 29 | } |
29 | } |
| 30 | THREAD_PARAM; |
30 | THREAD_PARAM; |
| 31 | 31 | ||
| 32 | class rlThread |
32 | class rlThread |
| 33 | { |
33 | { |
| 34 | public: |
34 | public: |
| 35 | rlThread(int max_semphore=1000); |
35 | rlThread(int max_semphore=1000); |
| 36 | ~rlThread(); |
36 | ~rlThread(); |
| 37 | int create(void *(*func)(void*), void *argument); |
37 | int create(void *(*func)(void*), void *argument); |
| 38 | 38 | ||
| 39 | int trylock(); |
39 | int trylock(); |
| 40 | 40 | ||
| 41 | int lock(); |
41 | int lock(); |
| 42 | 42 | ||
| 43 | int unlock(); |
43 | int unlock(); |
| 44 | 44 | ||
| 45 | int waitSemaphore(); |
45 | int waitSemaphore(); |
| 46 | 46 | ||
| 47 | int incrementSemaphore(); |
47 | int incrementSemaphore(); |
| 48 | 48 | ||
| 49 | int join(void **status); |
49 | int join(void **status); |
| 50 | 50 | ||
| 51 | int cancel(); |
51 | int cancel(); |
| 52 | 52 | ||
| 53 | void threadExit(void *status); |
53 | void threadExit(void *status); |
| 54 | 54 | ||
| 55 | pthread_t tid; |
55 | pthread_t tid; |
| 56 | pthread_attr_t attr; |
56 | pthread_attr_t attr; |
| 57 | pthread_mutex_t mutex; |
57 | pthread_mutex_t mutex; |
| 58 | WSEMAPHORE semaphore; |
58 | WSEMAPHORE semaphore; |
| 59 | private: |
59 | private: |
| 60 | THREAD_PARAM arg; |
60 | THREAD_PARAM arg; |
| 61 | }; |
61 | }; |
| 62 | 62 | ||
| 63 | class rlMutex |
63 | class rlMutex |
| 64 | { |
64 | { |
| 65 | public: |
65 | public: |
| 66 | rlMutex(const pthread_mutexattr_t *attr = NULL); |
66 | rlMutex(const pthread_mutexattr_t *attr = NULL); |
| 67 | ~rlMutex(); |
67 | ~rlMutex(); |
| 68 | 68 | ||
| 69 | int trylock(); |
69 | int trylock(); |
| 70 | 70 | ||
| 71 | int lock(); |
71 | int lock(); |
| 72 | 72 | ||
| 73 | int unlock(); |
73 | int unlock(); |
| 74 | 74 | ||
| 75 | pthread_mutex_t mutex; |
75 | pthread_mutex_t mutex; |
| 76 | }; |
76 | }; |
| 77 | 77 | ||
| 78 | class rlSemaphore |
78 | class rlSemaphore |
| 79 | { |
79 | { |
| 80 | public: |
80 | public: |
| 81 | rlSemaphore(int max_semaphore = 1000); |
81 | rlSemaphore(int max_semaphore = 1000); |
| 82 | ~rlSemaphore(); |
82 | ~rlSemaphore(); |
| 83 | 83 | ||
| 84 | int waitSemaphore(); |
84 | int waitSemaphore(); |
| 85 | 85 | ||
| 86 | int incrementSemaphore(); |
86 | int incrementSemaphore(); |
| 87 | 87 | ||
| 88 | WSEMAPHORE semaphore; |
88 | WSEMAPHORE semaphore; |
| 89 | }; |
89 | }; |
| 90 | 90 | ||
| 91 | #endif |
91 | #endif |
| 92 | 92 | ||