00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
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
00242