A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
watchdog.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
#include "
watchdog.h
"
9
10
#include "
log.h
"
11
12
/**
13
* \file
14
* \ingroup timer
15
* ns3::Watchdog timer class implementation.
16
*/
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"Watchdog"
);
22
23
Watchdog::Watchdog
()
24
: m_impl(nullptr),
25
m_event(),
26
m_end(
MicroSeconds
(0))
27
{
28
NS_LOG_FUNCTION_NOARGS
();
29
}
30
31
Watchdog::~Watchdog
()
32
{
33
NS_LOG_FUNCTION
(
this
);
34
m_event
.
Cancel
();
35
delete
m_impl
;
36
}
37
38
void
39
Watchdog::Ping
(
Time
delay)
40
{
41
NS_LOG_FUNCTION
(
this
<< delay);
42
Time
end =
Simulator::Now
() + delay;
43
m_end
= std::max(
m_end
, end);
44
if
(
m_event
.
IsPending
())
45
{
46
return
;
47
}
48
m_event
=
Simulator::Schedule
(
m_end
-
Now
(), &
Watchdog::Expire
,
this
);
49
}
50
51
void
52
Watchdog::Expire
()
53
{
54
NS_LOG_FUNCTION
(
this
);
55
if
(
m_end
==
Simulator::Now
())
56
{
57
m_impl
->
Invoke
();
58
}
59
else
60
{
61
m_event
=
Simulator::Schedule
(
m_end
-
Now
(), &
Watchdog::Expire
,
this
);
62
}
63
}
64
65
}
// namespace ns3
ns3::EventId::Cancel
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition
event-id.cc:44
ns3::EventId::IsPending
bool IsPending() const
This method is syntactic sugar for !IsExpired().
Definition
event-id.cc:65
ns3::Simulator::Schedule
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition
simulator.h:560
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition
simulator.cc:197
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::Watchdog::m_impl
internal::TimerImpl * m_impl
The timer implementation, which contains the bound callback function and arguments.
Definition
watchdog.h:112
ns3::Watchdog::Expire
void Expire()
Internal callback invoked when the timer expires.
Definition
watchdog.cc:52
ns3::Watchdog::m_event
EventId m_event
The future event scheduled to expire the timer.
Definition
watchdog.h:114
ns3::Watchdog::~Watchdog
~Watchdog()
Destructor.
Definition
watchdog.cc:31
ns3::Watchdog::Watchdog
Watchdog()
Constructor.
Definition
watchdog.cc:23
ns3::Watchdog::Ping
void Ping(Time delay)
Delay the timer.
Definition
watchdog.cc:39
ns3::Watchdog::m_end
Time m_end
The absolute time when the timer will expire.
Definition
watchdog.h:116
ns3::internal::TimerImpl::Invoke
virtual void Invoke()=0
Invoke the expire function.
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
ns3::Now
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition
simulator.cc:294
ns3::MicroSeconds
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition
nstime.h:1332
log.h
Debug message logging.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
watchdog.h
ns3::Watchdog timer class declaration.
src
core
model
watchdog.cc
Generated on Wed Oct 9 2024 01:03:23 for ns-3 by
1.11.0