Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | 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 "csutil/ref.h" 00023 #include "csutil/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_CRYSTALSPACE_EXPORT csRunnable 00052 { 00053 // Jorrit: removed the code below as it causes 'pure virtual' method 00054 // calls to happen upon destruction. 00055 //protected: 00058 //virtual ~csRunnable() {} 00059 public: 00061 virtual void Run () = 0; 00062 00063 /* maybe we could add those for smoother exit/cancel/detroy operations 00064 virtual void PrepareExit () = 0; 00065 virtual void PrepareJoin () = 0; 00066 virtual void PrepareKill () = 0; 00067 virtual void PrepareCancel () = 0; 00068 virtual void PrepareDestroy () = 0; 00069 */ 00070 00072 virtual void IncRef() = 0; 00074 virtual void DecRef() = 0; 00076 virtual int GetRefCount() = 0; 00077 }; 00078 00079 00083 class CS_CRYSTALSPACE_EXPORT csThread : public csRefCount 00084 { 00085 public: 00090 static csRef<csThread> Create (csRunnable*, uint32 options = 0); 00091 00096 virtual bool Start () = 0; 00097 00106 virtual bool Stop () = 0; 00107 00111 virtual bool Wait () = 0; 00112 00116 virtual void Yield () = 0; 00117 00121 virtual char const* GetLastError () const = 0; 00122 }; 00123 00124 00132 class CS_CRYSTALSPACE_EXPORT csMutex : public csRefCount 00133 { 00134 public: 00148 static csRef<csMutex> Create (bool recursive = false); 00149 00156 virtual bool LockWait() = 0; 00157 00164 virtual bool LockTry () = 0; 00165 00172 virtual bool Release () = 0; 00173 00177 virtual char const* GetLastError () const = 0; 00178 00182 virtual bool IsRecursive () const = 0; 00183 }; 00184 00185 00189 class CS_CRYSTALSPACE_EXPORT csSemaphore : public csRefCount 00190 { 00191 public: 00193 static csRef<csSemaphore> Create (uint32 value = 0); 00194 00201 virtual bool LockWait () = 0; 00202 00209 virtual bool LockTry () = 0; 00210 00217 virtual bool Release () = 0; 00218 00220 virtual uint32 Value () = 0; 00221 00225 virtual char const* GetLastError () const = 0; 00226 }; 00227 00228 00232 class CS_CRYSTALSPACE_EXPORT csCondition : public csRefCount 00233 { 00234 public: 00236 static csRef<csCondition> Create (uint32 conditionAttributes = 0); 00237 00246 virtual void Signal (bool WakeAll = false) = 0; 00247 00273 virtual bool Wait (csMutex* mutex, csTicks timeout = 0) = 0; 00274 00278 virtual char const* GetLastError () const = 0; 00279 }; 00280 00281 #endif // __CS_CSSYS_THREAD_H__
Generated for Crystal Space by doxygen 1.4.4