NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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
#include "
global-io.hpp
"
28
29
#include <boost/thread/tss.hpp>
30
31
namespace
nfd
{
32
namespace
scheduler {
33
34
static
boost::thread_specific_ptr<Scheduler>
g_scheduler
;
35
36
Scheduler&
37
getGlobalScheduler
()
38
{
39
static
ndn::DummyIoService
io;
40
if
(
g_scheduler
.get() ==
nullptr
) {
41
g_scheduler
.reset(
new
Scheduler(io));
42
}
43
44
return
*
g_scheduler
;
45
}
46
47
EventId
48
schedule
(time::nanoseconds after,
const
EventCallback
& event)
49
{
50
return
getGlobalScheduler
().scheduleEvent(after, event);
51
}
52
53
void
54
cancel
(
const
EventId
& eventId)
55
{
56
getGlobalScheduler
().cancelEvent(eventId);
57
}
58
59
void
60
resetGlobalScheduler
()
61
{
62
g_scheduler
.reset();
63
}
64
65
ScopedEventId::ScopedEventId
()
66
{
67
}
68
69
ScopedEventId::ScopedEventId
(
const
EventId
& event)
70
: m_event(event)
71
{
72
}
73
74
ScopedEventId::ScopedEventId
(
ScopedEventId
&& other)
75
: m_event(other.m_event)
76
{
77
other.release();
78
}
79
80
ScopedEventId
&
81
ScopedEventId::operator=
(
const
EventId
& event)
82
{
83
if
(m_event != event) {
84
scheduler::cancel
(m_event);
85
m_event = event;
86
}
87
return
*
this
;
88
}
89
90
ScopedEventId::~ScopedEventId
()
91
{
92
scheduler::cancel
(m_event);
93
}
94
95
void
96
ScopedEventId::cancel
()
97
{
98
scheduler::cancel
(m_event);
99
}
100
101
void
102
ScopedEventId::release
()
103
{
104
m_event.reset();
105
}
106
107
}
// namespace scheduler
108
}
// namespace nfd
ndn::util::scheduler::EventCallback
function< void()> EventCallback
Definition:
scheduler.hpp:46
nfd::scheduler::EventId
Opaque handle for a scheduled event.
nfd::scheduler::ScopedEventId::cancel
void cancel()
Cancels the event manually.
Definition:
scheduler.cpp:96
nfd::scheduler::ScopedEventId::operator=
ScopedEventId & operator=(const EventId &event)
Assigns an event.
Definition:
scheduler.cpp:81
nfd::scheduler::cancel
void cancel(const EventId &eventId)
Cancel a scheduled event.
Definition:
scheduler.cpp:54
nfd::scheduler::ScopedEventId::~ScopedEventId
~ScopedEventId()
Cancels the event.
Definition:
scheduler.cpp:90
ndn::util::scheduler::EventId
std::shared_ptr< ns3::EventId > EventId
Definition:
scheduler.hpp:51
nfd::scheduler::ScopedEventId::release
void release()
Releases the event so that it won't be cancelled when this ScopedEventId is destructed.
Definition:
scheduler.cpp:102
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
global-io.hpp
ndn::DummyIoService
Definition:
asio-fwd.hpp:27
nfd::scheduler::resetGlobalScheduler
void resetGlobalScheduler()
Definition:
scheduler.cpp:60
nfd::scheduler::ScopedEventId
Cancels an event automatically upon destruction.
Definition:
scheduler.hpp:60
nfd::scheduler::ScopedEventId::ScopedEventId
ScopedEventId()
Definition:
scheduler.cpp:65
scheduler.hpp
nfd::scheduler::g_scheduler
static boost::thread_specific_ptr< Scheduler > g_scheduler
Definition:
scheduler.cpp:34
nfd::scheduler::schedule
EventId schedule(time::nanoseconds after, const EventCallback &event)
Schedule an event.
Definition:
scheduler.cpp:48
nfd::scheduler::getGlobalScheduler
Scheduler & getGlobalScheduler()
Definition:
scheduler.cpp:37
ndnSIM
NFD
core
scheduler.cpp
Generated on Tue Aug 7 2018 16:19:17 for ndnSIM by
1.8.14