-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransmissionTimer.h
59 lines (52 loc) · 1.72 KB
/
TransmissionTimer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* File: TransmissionTimer.h
* Class: ICS 451
* Project #: 3
* Team Members: Bryce Groff, Brandon Grant, Emiliano Miranda
* Author: Emiliano Miranda
* Created Date: 04-22-09
* Desc: This file contains the declaration for the TransmissionTimer class
* which can act as a timed notification mechanism for transmissions.
*/
#ifndef _TRANSMISSION_TIMER_H_
#define _TRANSMISSION_TIMER_H_
#include <errno.h>
#include <pthread.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include "Mutex.h"
#include "Thread.h"
#define kTransmissionTimerInfiniteInterval -1
class TransmissionTimer
{
public:
TransmissionTimer(unsigned int milliSeconds, void* caller, void (*callBackFunc)(void*));
TransmissionTimer(unsigned int milliSeconds, int intervalCt, void* caller, void (*callBackFunc)(void*));
~TransmissionTimer();
int GetIntervalCount();
void SetIntervalCount(int intervalCt);
unsigned int GetTimerDelay();
void SetTimerDelay(unsigned int milliSeconds);
void Start(bool abortIfStarted);
void Start(bool abortIfStarted, unsigned int newDelayMilliSeconds);
void Stop();
private:
static void* _DoTimer(void *arg);
unsigned int mDelayMilliSecs;
int mIntervalCt;
//unsigned int mSecs;
//useconds_t mUsecs; // Unsigned int
void* mTimerCaller;
void (*mTimerCallBack)(void*);
volatile bool mIsRunning; // Protection against possiblity of multiple threads on different cores seeing different value in L1 cache.
volatile bool mIsPaused;
volatile bool mDoAbort;
time_t mSecs;
long mNanoSecs;
Mutex mMutex;
Thread mTimerThread;
//Thread* mOldTimerThread; // Used to stop an existing thread.
};
#endif