00001 /* 00002 * Copyright (C) 2009, Edmundo Albuquerque de Souza e Silva. 00003 * 00004 * This file may be distributed under the terms of the Q Public License 00005 * as defined by Trolltech AS of Norway and appearing in the file 00006 * LICENSE.QPL included in the packaging of this file. 00007 * 00008 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING 00009 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00010 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00012 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00013 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00014 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 * 00016 * Thanks: Jose Renato Santos 00017 * 00018 */ 00019 00020 /////////////////////////////////////////////////////////////////////////////// 00021 // vsithread.h: Definition of class that implements VSI threads 00022 // (VSI: Virtual System Interface) 00023 ////////////////////////////////////////////////////////////////////// 00024 00025 #if !defined __VSITHREAD_H_ 00026 #define __VSITHREAD_H_ 00027 00028 // POSIX threads 00029 #include <pthread.h> 00030 #include <limits.h> 00031 00032 const int VSI_THREAD_SCOPE_SYSTEM = 1; 00033 const int VSI_THREAD_SCOPE_PROCESS = 2; 00034 00035 00036 class CvsiThread 00037 { 00038 private: 00039 pthread_t m_Thread; 00040 int m_Stat; 00041 pthread_attr_t m_Attr; 00042 void* (*m_UserRoutine)(void*); 00043 void* m_Arg; 00044 00045 static void* Thread(void* Arg); 00046 00047 public: 00048 CvsiThread(); 00049 ~CvsiThread(); 00050 int IsActive (); 00051 int Create (void* (*StartRoutine)(void*), void* Arg); 00052 int Join (void **Result); 00053 int SetScope(int Scope); 00054 }; 00055 00056 00057 #endif // __VSITHREAD_H_