79 lines
2.0 KiB
C++
79 lines
2.0 KiB
C++
/*
|
|
* File: DetectionTimer.cc
|
|
* Author: jgaebler
|
|
*
|
|
* Created on May 20, 2010, 10:39 AM
|
|
*/
|
|
|
|
#include "DetectionTimer.h"
|
|
|
|
#include "fd/NetworkFailureDetector.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
#undef DEBUG
|
|
#define DEBUG(msg) if ( nfd.module.isPrintDebugNFD()) MOV_DEBUG << "NFD@" << nfd.dispatcher.getLocalID() << " "<<msg<<endl;
|
|
|
|
/**
|
|
* @brief Constructor
|
|
* @param aFd the NetworkFailureDetector, which owns this timer instance
|
|
*/
|
|
DetectionTimer::DetectionTimer(NetworkFailureDetector & aFd) : ReferenceTimer<PeerID>(aFd), fd(aFd) {
|
|
#if OMNETPP
|
|
setName("DETECTION_TIMER");
|
|
#endif
|
|
setNumberOfRetries(FD_NUMBER_OF_MAX_RETRIES);
|
|
setTimeout(DETECTION_TIMEOUT);
|
|
|
|
}
|
|
|
|
/**
|
|
* @brief Destructor
|
|
*/
|
|
DetectionTimer::~DetectionTimer() {
|
|
}
|
|
|
|
/**
|
|
* @brief Copy constructor
|
|
* @param orig The instance to copy.
|
|
*/
|
|
DetectionTimer::DetectionTimer(const DetectionTimer & orig) : ReferenceTimer<PeerID>(orig), fd(orig.fd) {
|
|
operator=(orig);
|
|
}
|
|
|
|
/**
|
|
* @brief Assignment operator
|
|
* @param other The instance to assign
|
|
* @return A reference to the local instance
|
|
*/
|
|
DetectionTimer &
|
|
DetectionTimer::operator=(const DetectionTimer & other) {
|
|
|
|
if (this != &other) {
|
|
fd = other.fd;
|
|
}//End if
|
|
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief A duplicate method. Duplicates the current timer.
|
|
* @return A reference to the new created timer.
|
|
*/
|
|
DetectionTimer*
|
|
DetectionTimer::dup() {
|
|
return new DetectionTimer(*this);
|
|
}
|
|
|
|
/**
|
|
* @brief If the timer is fired, this method is called and the timer
|
|
* handled.
|
|
*/
|
|
void
|
|
DetectionTimer::timeout() {
|
|
fd.handleDetectionTimer(this);
|
|
}
|
|
}
|
|
}
|