*NEXT/*DIE

This commit is contained in:
Brad committed 2023-06-19 23:22:46 +00:00
1 parent 48be555724
commit 9a39b6224c
14 files changed
+352 -209

No files matched your search

+57 -57
View File
@@ -1,66 +1,66 @@
#ifndef __Timer_h__
#define __Timer_h__
#include "Socket.h"
#include "EPoll.h"
#include "Socket.h"
namespace core {
///
/// Timer
///
/// Set and trigger callback upon specified timeout.
///
/// The Timer is used to establish a timer using the timer socket
/// interface. It cannot be instantiated directly but must be extended.
///
class Timer : Socket {
public:
namespace core
{
///
/// Timer
///
/// Set and trigger callback upon specified timeout.
///
/// The Timer is used to establish a timer using the timer socket
/// interface. It cannot be instantiated directly but must be extended.
///
class Timer : Socket
{
public:
Timer(EPoll &ePoll);
Timer(EPoll &ePoll, double delay);
~Timer();
///
/// Use the setTimer() method to set the time out value for timer. Setting the timer
/// also starts the timer countdown. The clearTimer() method can be used to reset
/// the timer without triggering the onTimeout() callback.
///
/// @param delay the amount of time in seconds to wait before trigering the onTimeout function.
///
void setTimer(double delay);
///
/// Use the clearTimer() to unset the timer and return the timer to an idle state.
///
void clearTimer();
///
/// Use the getElapsed() method to obtain the amount of time that has elapsed since
/// the timer was set.
///
double getElapsed();
double getEpoch();
protected:
///
/// This method is called when the time out occurs.
///
virtual void onTimeout() = 0;
private:
void onDataReceived(std::string data) override;
double delayValue;
};
Timer(EPoll &ePoll, double delay);
~Timer();
///
/// Use the setTimer() method to set the time out value for timer. Setting the timer
/// also starts the timer countdown. The clearTimer() method can be used to reset
/// the timer without triggering the onTimeout() callback.
///
/// @param delay the amount of time in seconds to wait before trigering the onTimeout function.
///
void setTimer(double delay);
///
/// Use the clearTimer() to unset the timer and return the timer to an idle state.
///
void clearTimer();
///
/// Use the getElapsed() method to obtain the amount of time that has elapsed since
/// the timer was set.
///
double getElapsed();
double getEpoch();
protected:
///
/// This method is called when the time out occurs.
///
virtual void onTimeout() = 0;
private:
void onDataReceived(std::string data) override;
double delayValue;
};
}
#endif