Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
thread.h
00001 /* 00002 Copyright (C) 2002 by Norman Kraemer 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_CSSYS_THREAD_H__ 00020 #define __CS_CSSYS_THREAD_H__ 00021 00022 #include "ref.h" 00023 #include "refcount.h" 00024 00026 enum 00027 { 00028 CS_THREAD_NO_ERROR = 0, 00029 CS_THREAD_UNKNOWN_ERROR, 00030 CS_THREAD_OUT_OF_RESOURCES, 00031 CS_THREAD_ERR_ATTRIBUTE, 00032 CS_THREAD_NO_PERMISSION, 00033 CS_THREAD_UNKNOWN_THREAD, 00034 CS_THREAD_DEADLOCK, 00035 CS_THREAD_OPERATION_PENDING, 00036 CS_THREAD_MUTEX_NOT_INITIALIZED, 00037 CS_THREAD_MUTEX_BUSY, 00038 CS_THREAD_MUTEX_UNKNOWN, 00039 CS_THREAD_CONDITION_TIMEOUT, 00040 CS_THREAD_CONDITION_BUSY, 00041 CS_THREAD_CONDITION_WAIT_INTERRUPTED, 00042 CS_THREAD_SIGNAL_UNKNOWN, 00043 CS_THREAD_SEMA_VALUE_TOO_LARGE, 00044 CS_THREAD_SEMA_BUSY 00045 }; 00046 00051 class CS_CSUTIL_EXPORT csRunnable 00052 { 00053 public: 00055 virtual void Run () = 0; 00056 00057 /* maybe we could add those for smoother exit/cancel/detroy operations 00058 virtual void PrepareExit () = 0; 00059 virtual void PrepareJoin () = 0; 00060 virtual void PrepareKill () = 0; 00061 virtual void PrepareCancel () = 0; 00062 virtual void PrepareDestroy () = 0; 00063 */ 00064 00066 virtual void IncRef() = 0; 00068 virtual void DecRef() = 0; 00070 virtual int GetRefCount() = 0; 00071 }; 00072 00073 00077 class CS_CSUTIL_EXPORT csThread : public csRefCount 00078 { 00079 public: 00084 static csRef<csThread> Create (csRunnable*, uint32 options = 0); 00085 00090 virtual bool Start () = 0; 00091 00100 virtual bool Stop () = 0; 00101 00105 virtual bool Wait () = 0; 00106 00110 virtual void Yield () = 0; 00111 00115 virtual char const* GetLastError () const = 0; 00116 }; 00117 00118 00126 class CS_CSUTIL_EXPORT csMutex : public csRefCount 00127 { 00128 public: 00141 static csRef<csMutex> Create (bool recursive = false); 00142 00149 virtual bool LockWait() = 0; 00150 00157 virtual bool LockTry () = 0; 00158 00165 virtual bool Release () = 0; 00166 00170 virtual char const* GetLastError () const = 0; 00171 00175 virtual bool IsRecursive () const = 0; 00176 }; 00177 00178 00182 class CS_CSUTIL_EXPORT csSemaphore : public csRefCount 00183 { 00184 public: 00186 static csRef<csSemaphore> Create (uint32 value = 0); 00187 00194 virtual bool LockWait () = 0; 00195 00202 virtual bool LockTry () = 0; 00203 00210 virtual bool Release () = 0; 00211 00213 virtual uint32 Value () = 0; 00214 00218 virtual char const* GetLastError () const = 0; 00219 }; 00220 00221 00225 class CS_CSUTIL_EXPORT csCondition : public csRefCount 00226 { 00227 public: 00229 static csRef<csCondition> Create (uint32 conditionAttributes = 0); 00230 00239 virtual void Signal (bool WakeAll = false) = 0; 00240 00266 virtual bool Wait (csMutex* mutex, csTicks timeout = 0) = 0; 00267 00271 virtual char const* GetLastError () const = 0; 00272 }; 00273 00274 #endif // __CS_CSSYS_THREAD_H__
Generated for Crystal Space by doxygen 1.3.9.1