00001 //=========================================================================== 00002 /* 00003 This file is part of the CHAI 3D visualization and haptics libraries. 00004 Copyright (C) 2003-2009 by CHAI 3D. All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License("GPL") version 2 00008 as published by the Free Software Foundation. 00009 00010 For using the CHAI 3D libraries with software that can not be combined 00011 with the GNU GPL, and for taking advantage of the additional benefits 00012 of our support services, please contact CHAI 3D about acquiring a 00013 Professional Edition License. 00014 00015 \author <http://www.chai3d.org> 00016 \author Francois Conti 00017 \version 2.0.0 $Rev: 251 $ 00018 */ 00019 //=========================================================================== 00020 00021 //--------------------------------------------------------------------------- 00022 #ifndef CThreadH 00023 #define CThreadH 00024 //--------------------------------------------------------------------------- 00025 #include "extras/CGlobals.h" 00026 //--------------------------------------------------------------------------- 00027 00028 //=========================================================================== 00036 //=========================================================================== 00037 00038 //--------------------------------------------------------------------------- 00043 //--------------------------------------------------------------------------- 00044 enum CThreadPriority 00045 { 00046 CHAI_THREAD_PRIORITY_GRAPHICS, 00047 CHAI_THREAD_PRIORITY_HAPTICS 00048 }; 00049 00050 00051 //=========================================================================== 00059 //=========================================================================== 00060 class cThread 00061 { 00062 public: 00063 00064 //----------------------------------------------------------------------- 00065 // CONSTRUCTOR & DESTRUCTOR: 00066 //----------------------------------------------------------------------- 00067 00069 cThread(); 00070 00072 ~cThread(); 00073 00074 00075 //----------------------------------------------------------------------- 00076 // METHODS: 00077 //----------------------------------------------------------------------- 00078 00080 void set(void (*a_function)(void), CThreadPriority a_level); 00081 00083 void setPriority(CThreadPriority a_level); 00084 00086 CThreadPriority getPriority() { return (m_priorityLevel); } 00087 00088 00089 protected: 00090 00091 #if defined(_WIN32) 00093 DWORD m_threadId; 00094 #endif 00095 00096 #if defined(_LINUX) || defined(_MACOSX) 00098 pthread_t m_handle; 00099 #endif 00100 00102 void* m_function; 00103 00105 CThreadPriority m_priorityLevel; 00106 }; 00107 00108 //--------------------------------------------------------------------------- 00109 #endif 00110 //---------------------------------------------------------------------------