Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MNThread.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef MN_OSS_THREAD_H 00025 #define MN_OSS_THREAD_H 00026 00027 #include <config.h> 00028 #include <sys/types.h> 00029 #include <unistd.h> 00030 00031 #include "mnthread.h" 00032 #include "MNString.h" 00033 #include "MNValid.h" 00034 00035 #define READ 0 00036 #define WRITE 1 00037 00038 struct procent { 00039 pid_t pid; 00040 mnthread_t tid; 00041 const char* procname; 00042 }; 00043 00044 00045 class MNThread 00046 { 00047 DECLARE_VALID 00048 00049 bool _detach; 00050 mnthread_attr_t _ta; 00051 mnthread_t _t; 00052 MNString _name; 00053 00054 public: 00055 MNThread ( const char* name, bool detach = false ); 00056 MNThread ( bool detach = false ); 00057 virtual ~MNThread ( ); 00058 00059 int start(); 00060 void join(); 00061 void exit(); 00062 const MNString& threadName() const; 00063 00064 mnthread_t id() const; 00065 static mnthread_t current(); 00066 bool operator==( mnthread_t t ); 00067 bool operator!=( mnthread_t t ); 00068 00069 virtual void run () = 0; 00070 }; 00071 00072 template <class T> class NeighThread 00073 : public MNThread 00074 { 00075 typedef void (T::*func)(); 00076 00077 T* _object; 00078 func _memfunc; 00079 public: 00080 00081 NeighThread( T* object, func memfunc ) 00082 : MNThread(true) 00083 , _object(object) 00084 , _memfunc(memfunc) 00085 { } 00086 00087 virtual void run() 00088 { 00089 (_object->*_memfunc)(); 00090 } 00091 }; 00092 00093 #endif /* MN_OSS_THREAD_H */ 00094

Generated on Sun Mar 6 13:35:49 2005 for Komssys by doxygen 1.3.8