NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
scheduler.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#include "
scheduler.hpp
"
27
28
namespace
ns3 {
29
31
32
template
<>
33
struct
EventMemberImplObjTraits<std::function<void()>> {
34
typedef
std::function<void()> T;
35
static
T&
36
GetReference(T& p)
37
{
38
return
p;
39
}
40
};
41
43
44
}
// namespace ns3
45
46
namespace
nfd {
47
namespace
scheduler {
48
49
EventId
50
schedule
(
const
time::nanoseconds& after,
const
std::function<
void
()>& event)
51
{
52
ns3::EventId
id
= ns3::Simulator::Schedule(ns3::NanoSeconds(after.count()),
53
&std::function<
void
()>::operator(), event);
54
return
std::make_shared<ns3::EventId>(id);
55
}
56
57
void
58
cancel
(
const
EventId
& eventId)
59
{
60
if
(eventId !=
nullptr
) {
61
ns3::Simulator::Remove(*eventId);
62
const_cast<
EventId
&
>
(eventId).reset();
63
}
64
}
65
66
ScopedEventId::ScopedEventId
()
67
{
68
}
69
70
ScopedEventId::ScopedEventId
(
const
EventId
& event)
71
: m_event(event)
72
{
73
}
74
75
ScopedEventId::ScopedEventId
(
ScopedEventId
&& other)
76
: m_event(other.m_event)
77
{
78
other.release();
79
}
80
81
ScopedEventId
&
82
ScopedEventId::operator=
(
const
EventId
& event)
83
{
84
if
(m_event != event) {
85
scheduler::cancel
(m_event);
86
m_event = event;
87
}
88
return
*
this
;
89
}
90
91
ScopedEventId::~ScopedEventId
()
92
{
93
scheduler::cancel
(m_event);
94
}
95
96
void
97
ScopedEventId::cancel
()
98
{
99
scheduler::cancel
(m_event);
100
}
101
102
void
103
ScopedEventId::release
()
104
{
105
m_event.reset();
106
}
107
108
}
// namespace scheduler
109
}
// namespace nfd
nfd::scheduler::ScopedEventId::cancel
void cancel()
cancels the event manually
Definition:
scheduler.cpp:97
nfd::scheduler::ScopedEventId::operator=
ScopedEventId & operator=(const EventId &event)
assigns an event
Definition:
scheduler.cpp:82
nfd::scheduler::cancel
void cancel(const EventId &eventId)
cancel a scheduled event
Definition:
scheduler.cpp:58
nfd::scheduler::ScopedEventId::~ScopedEventId
~ScopedEventId()
cancels the event
Definition:
scheduler.cpp:91
nfd::scheduler::EventId
std::shared_ptr< ns3::EventId > EventId
Definition:
scheduler.hpp:39
EventId
Opaque type (shared_ptr) representing ID of a scheduled event.
nfd::scheduler::ScopedEventId::release
void release()
releases the event so that it won't be disconnected when this ScopedEventId is destructed ...
Definition:
scheduler.cpp:103
scheduler.hpp
nfd::scheduler::ScopedEventId
cancels an event automatically upon destruction
Definition:
scheduler.hpp:53
nfd::scheduler::ScopedEventId::ScopedEventId
ScopedEventId()
Definition:
scheduler.cpp:66
nfd::scheduler::schedule
EventId schedule(const time::nanoseconds &after, const std::function< void()> &event)
schedule an event
Definition:
scheduler.cpp:50
ndnSIM
NFD
core
scheduler.cpp
Generated on Wed Feb 18 2015 16:31:16 for ndnSIM by
1.8.7