A very simple watchdog operating in virtual time. More...
#include "watchdog.h"
Public Member Functions | |
Watchdog () | |
Constructor. More... | |
~Watchdog () | |
Destructor. More... | |
void | Ping (Time delay) |
Delay the timer. More... | |
template<typename FN > | |
void | SetFunction (FN fn) |
Set the function to execute when the timer expires. More... | |
template<typename MEM_PTR , typename OBJ_PTR > | |
void | SetFunction (MEM_PTR memPtr, OBJ_PTR objPtr) |
Set the function to execute when the timer expires. More... | |
template<typename T1 > | |
void | SetArguments (T1 a1) |
Set the arguments to be used when invoking the expire function. More... | |
template<typename T1 , typename T2 > | |
void | SetArguments (T1 a1, T2 a2) |
template<typename T1 , typename T2 , typename T3 > | |
void | SetArguments (T1 a1, T2 a2, T3 a3) |
template<typename T1 , typename T2 , typename T3 , typename T4 > | |
void | SetArguments (T1 a1, T2 a2, T3 a3, T4 a4) |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 > | |
void | SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 > | |
void | SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) |
Private Member Functions | |
void | Expire (void) |
Internal callback invoked when the timer expires. More... | |
Private Attributes | |
Time | m_end |
The absolute time when the timer will expire. More... | |
EventId | m_event |
The future event scheduled to expire the timer. More... | |
TimerImpl * | m_impl |
The timer implementation, which contains the bound callback function and arguments. More... | |
A very simple watchdog operating in virtual time.
The watchdog timer is started by calling Ping with a delay value. Once started the timer cannot be suspended, cancelled or shortened. It can be lengthened (delayed) by calling Ping again: if the new expire time (current simulation time plus the new delay) is greater than the old expire time the timer will be extended to the new expire time.
Typical usage would be to periodically Ping the Watchdog, extending it's execution time. If the owning process fails to Ping before the Watchdog expires, the registered function will be invoked.
If you don't ping the watchdog sufficiently often, it triggers its listening function.
Definition at line 56 of file watchdog.h.
ns3::Watchdog::Watchdog | ( | ) |
ns3::Watchdog::~Watchdog | ( | ) |
|
private |
Internal callback invoked when the timer expires.
Definition at line 62 of file watchdog.cc.
References ns3::TimerImpl::Invoke(), m_end, m_event, m_impl, ns3::Now(), ns3::Simulator::Now(), NS_LOG_FUNCTION, and ns3::Simulator::Schedule().
Referenced by Ping().
void ns3::Watchdog::Ping | ( | Time | delay | ) |
Delay the timer.
[in] | delay | The watchdog delay |
After a call to this method, the watchdog will not be triggered until the delay specified has been expired. This operation is sometimes named "re-arming" a watchdog in some operating systems.
Definition at line 49 of file watchdog.cc.
References Expire(), ns3::EventId::IsRunning(), m_end, m_event, max, ns3::Now(), ns3::Simulator::Now(), NS_LOG_FUNCTION, and ns3::Simulator::Schedule().
Referenced by ns3::tests::WatchdogTestCase::DoRun().
void ns3::Watchdog::SetArguments | ( | T1 | a1 | ) |
Set the arguments to be used when invoking the expire function.
T1 | [deduced] Type of the first argument. |
[in] | a1 | The first argument |
Definition at line 214 of file watchdog.h.
References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().
Referenced by ns3::tests::WatchdogTestCase::DoRun().
void ns3::Watchdog::SetArguments | ( | T1 | a1, |
T2 | a2 | ||
) |
T1 | [deduced] Type of the first argument. |
T2 | [deduced] Type of the second argument. |
[in] | a1 | the first argument |
[in] | a2 | the second argument |
Definition at line 225 of file watchdog.h.
References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().
void ns3::Watchdog::SetArguments | ( | T1 | a1, |
T2 | a2, | ||
T3 | a3 | ||
) |
T1 | [deduced] Type of the first argument. |
T2 | [deduced] Type of the second argument. |
T3 | [deduced] Type of the third argument. |
[in] | a1 | the first argument |
[in] | a2 | the second argument |
[in] | a3 | the third argument |
Definition at line 237 of file watchdog.h.
References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().
void ns3::Watchdog::SetArguments | ( | T1 | a1, |
T2 | a2, | ||
T3 | a3, | ||
T4 | a4 | ||
) |
T1 | [deduced] Type of the first argument. |
T2 | [deduced] Type of the second argument. |
T3 | [deduced] Type of the third argument. |
T4 | [deduced] Type of the fourth argument. |
[in] | a1 | the first argument |
[in] | a2 | the second argument |
[in] | a3 | the third argument |
[in] | a4 | the fourth argument |
Definition at line 249 of file watchdog.h.
References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().
void ns3::Watchdog::SetArguments | ( | T1 | a1, |
T2 | a2, | ||
T3 | a3, | ||
T4 | a4, | ||
T5 | a5 | ||
) |
T1 | [deduced] Type of the first argument. |
T2 | [deduced] Type of the second argument. |
T3 | [deduced] Type of the third argument. |
T4 | [deduced] Type of the fourth argument. |
T5 | [deduced] Type of the fifth argument. |
[in] | a1 | the first argument |
[in] | a2 | the second argument |
[in] | a3 | the third argument |
[in] | a4 | the fourth argument |
[in] | a5 | the fifth argument |
Definition at line 261 of file watchdog.h.
References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().
void ns3::Watchdog::SetArguments | ( | T1 | a1, |
T2 | a2, | ||
T3 | a3, | ||
T4 | a4, | ||
T5 | a5, | ||
T6 | a6 | ||
) |
T1 | [deduced] Type of the first argument. |
T2 | [deduced] Type of the second argument. |
T3 | [deduced] Type of the third argument. |
T4 | [deduced] Type of the fourth argument. |
T5 | [deduced] Type of the fifth argument. |
T6 | [deduced] Type of the sixth argument. |
[in] | a1 | the first argument |
[in] | a2 | the second argument |
[in] | a3 | the third argument |
[in] | a4 | the fourth argument |
[in] | a5 | the fifth argument |
[in] | a6 | the sixth argument |
Definition at line 273 of file watchdog.h.
References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().
void ns3::Watchdog::SetFunction | ( | FN | fn | ) |
Set the function to execute when the timer expires.
[in] | fn | The function |
Store this function in this Timer for later use by Timer::Schedule.
Definition at line 199 of file watchdog.h.
References m_impl, and ns3::MakeTimerImpl().
Referenced by ns3::tests::WatchdogTestCase::DoRun().
void ns3::Watchdog::SetFunction | ( | MEM_PTR | memPtr, |
OBJ_PTR | objPtr | ||
) |
Set the function to execute when the timer expires.
MEM_PTR | [deduced] Class method function type. |
OBJ_PTR | [deduced] Class type containing the function. |
[in] | memPtr | The member function pointer |
[in] | objPtr | The pointer to object |
Store this function and object in this Timer for later use by Timer::Schedule.
Definition at line 206 of file watchdog.h.
References m_impl, and ns3::MakeTimerImpl().
|
private |
The absolute time when the timer will expire.
Definition at line 182 of file watchdog.h.
|
private |
The future event scheduled to expire the timer.
Definition at line 180 of file watchdog.h.
|
private |
The timer implementation, which contains the bound callback function and arguments.
Definition at line 178 of file watchdog.h.
Referenced by Expire(), SetArguments(), SetFunction(), and ~Watchdog().