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

MNTimer.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_TIMER_H 00025 #define MN_TIMER_H 00026 00027 #include <sys/time.h> 00028 #include <sys/types.h> 00029 #include <unistd.h> 00030 #include <string.h> 00031 #include "MNThread.h" 00032 #include "MNMutex.h" 00033 #include "MNTimerCall.h" 00034 #include "MNTimerEntry.h" 00035 #include "MNProtectedVar.h" 00036 #include "MNTimeval.h" 00037 #include "MNSelector.h" 00038 #include "dictionary.h" 00039 00040 class MNTimer; 00041 class AutonomousTimer; 00042 00043 /*********************************************************************** 00044 * MNTimer 00045 ***********************************************************************/ 00046 00054 class MNTimer 00055 { 00056 MNSelector& _sel; 00057 00058 public: 00059 static const bool InCallback = true; 00060 static const bool NotInCallback = false; 00061 00062 public: 00065 MNTimer( MNSelector& selector, const char* debug_creator_string ); 00066 00069 virtual ~MNTimer( ); 00070 00088 void insert_abs_timer( TimerCallBase* timerptr, 00089 const struct timeval& timeout, 00090 bool inCallback, 00091 const char* owner ); 00092 00103 void reschedule_abs_timer( TimerCallBase* timerptr, 00104 const struct timeval& timeout, 00105 bool inCallback, 00106 const char* owner ); 00107 00118 void insert_rel_timer( TimerCallBase* timerptr, 00119 const struct timeval& timeout, 00120 bool inCallback, 00121 const char* owner ); 00122 00133 void reschedule_rel_timer( TimerCallBase* timerptr, 00134 const struct timeval& timeout, 00135 bool inCallback, 00136 const char* owner ); 00137 00150 void insert_periodic_timer( TimerCallBase* timerptr, 00151 const struct timeval& timeout, 00152 bool inCallback, 00153 const char* owner ); 00154 00162 void cancel_timer( TimerCallBase* timerptr ); 00163 00166 void cancel_all_timer(); 00167 00173 void wait_usec(long time_); 00174 00176 virtual void start_timer(); 00177 00179 virtual void terminate_timer(); 00180 00185 MNSelector& getSelector( ); 00186 private: 00188 MNTimer( const MNTimer& ); 00190 MNTimer& operator=( const MNTimer& ); 00191 }; 00192 00193 /*********************************************************************** 00194 * AutonomousTimer 00195 ***********************************************************************/ 00196 00197 class AutonomousTimer : public MNTimer 00198 , public MNThread 00199 { 00200 MNSelector _autonomous_selector; 00201 00203 ProtectedBool _started; 00204 00208 ProtectedBool _ende; 00209 00211 MNMutex _initialized; 00212 00216 virtual void run(); 00217 00218 public: 00221 AutonomousTimer( const char* debug_creator_string ); 00222 00226 virtual ~AutonomousTimer( ); 00227 00230 virtual void start_timer(); 00231 00238 virtual void terminate_timer(); 00239 }; 00240 00241 #endif /* MN_TIMER_H */ 00242

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