|
rllib
1
|
00001 /*************************************************************************** 00002 rlthread.h - description 00003 ------------------- 00004 begin : Tue Jan 02 2001 00005 copyright : (C) 2001 by Rainer Lehrig 00006 email : lehrig@t-online.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This library is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as * 00013 * published by the Free Software Foundation * 00014 * * 00015 ***************************************************************************/ 00016 #ifndef _RL_THREAD_H_ 00017 #define _RL_THREAD_H_ 00018 00019 #include "rldefine.h" 00020 #include "rlwthread.h" 00021 00022 class rlThread; 00023 00027 typedef struct 00028 { 00029 rlThread *thread; 00030 void *user; 00031 int running; 00032 } 00033 THREAD_PARAM; 00034 00038 class rlThread 00039 { 00040 public: 00041 rlThread(int max_semphore=1000); 00042 virtual ~rlThread(); 00063 int create(void *(*func)(void*), void *argument); 00064 00070 int trylock(); 00071 00075 int lock(); 00076 00080 int unlock(); 00081 00085 int waitSemaphore(); 00086 00090 int incrementSemaphore(); 00091 00095 int join(void **status); 00096 00100 int cancel(); 00101 00105 void threadExit(void *status); 00106 00107 pthread_t tid; 00108 pthread_attr_t attr; 00109 pthread_mutex_t mutex; 00110 WSEMAPHORE semaphore; 00111 private: 00112 THREAD_PARAM arg; 00113 }; 00114 00118 class rlMutex 00119 { 00120 public: 00121 rlMutex(const pthread_mutexattr_t *attr = NULL); 00122 virtual ~rlMutex(); 00123 00129 int trylock(); 00130 00134 int lock(); 00135 00139 int unlock(); 00140 00141 pthread_mutex_t mutex; 00142 }; 00143 00147 class rlSemaphore 00148 { 00149 public: 00150 rlSemaphore(int max_semaphore = 1000); 00151 virtual ~rlSemaphore(); 00152 00156 int waitSemaphore(); 00157 00161 int incrementSemaphore(); 00162 00163 WSEMAPHORE semaphore; 00164 }; 00165 00166 #endif
1.7.5.1