| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeThread.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00029 #ifndef __TERRALIB_INTERNAL_TETRHEAD_H
    00030 #define __TERRALIB_INTERNAL_TETRHEAD_H
    00031
    00032 #include "TeThreadDatatypes.h"
    00033 #include "TeDefines.h"
    00034
    00035 #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
    00036 #include <windows.h>
    00037 #define TeDelayThread( seconds ) Sleep( seconds * 1000)
    00038 #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX || TePLATFORM == TePLATFORMCODE_APPLE
    00039 #include <pthread.h>
    00040 #include <unistd.h>
    00041 #define TeDelayThread( seconds ) sleep( seconds )
    00042 #else
    00043 #error "ERROR: Unsupported platform"
    00044 #endif
    00045
    00046
    00067 class TL_DLL TeThread
    00068 {
    00069   public :
    00070
    00073     TeThread();
    00074
    00077     virtual ~TeThread();
    00078
    00082     bool start();
    00083
    00087     TeThreadStatus getStatus() const;
    00088
    00092     TeThreadPriority getPriority() const;
    00093
    00098     bool setPriority(TeThreadPriority newPriority);
    00099
    00104     bool waitToFinish();
    00105
    00106            protected:
    00107
    00111                       virtual void run() = 0;
    00112
    00113            private:
    00114
    00118                       static void* startThread(void* threadPtr );
    00119
    00123                       TeThread(const TeThread& rhs);
    00124
    00129                       const TeThread& operator=(const TeThread& rhs);
    00130
    00131            protected:
    00132
    00133 #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
    00134     HANDLE threadHandler_;
    00135                       LPDWORD threadId_;
    00136 #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX || TePLATFORM == TePLATFORMCODE_APPLE
    00137                       pthread_t threadId_;
    00138                       pthread_attr_t threadAttr_;
    00139 #else
    00140 #error "ERROR: Unsupported platform"
    00141 #endif
    00142
    00143     volatile TeThreadStatus threadStatus_;
    00144     volatile TeThreadPriority threadCurrPriority_;
    00145 };
    00146
    00147 #endif     // __TERRALIB_INTERNAL_TETRHEAD_H
    00148

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines