NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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
if
(g_scheduler.get() ==
nullptr
) {
40
g_scheduler.reset(
new
Scheduler(*static_cast<boost::asio::io_service*>(
nullptr
)));
41
}
42
43
return
*
g_scheduler
;
44
}
45
46
EventId
47
schedule
(
const
time::nanoseconds& after,
const
Scheduler::Event& event)
48
{
49
return
getGlobalScheduler
().scheduleEvent(after, event);
50
}
51
52
void
53
cancel
(
const
EventId
& eventId)
54
{
55
getGlobalScheduler
().cancelEvent(eventId);
56
}
57
58
void
59
resetGlobalScheduler
()
60
{
61
g_scheduler.reset();
62
}
63
64
ScopedEventId::ScopedEventId
()
65
{
66
}
67
68
ScopedEventId::ScopedEventId
(
const
EventId
& event)
69
: m_event(event)
70
{
71
}
72
73
ScopedEventId::ScopedEventId
(
ScopedEventId
&& other)
74
: m_event(other.m_event)
75
{
76
other.release();
77
}
78
79
ScopedEventId
&
80
ScopedEventId::operator=
(
const
EventId
& event)
81
{
82
if
(m_event != event) {
83
scheduler::cancel
(m_event);
84
m_event = event;
85
}
86
return
*
this
;
87
}
88
89
ScopedEventId::~ScopedEventId
()
90
{
91
scheduler::cancel
(m_event);
92
}
93
94
void
95
ScopedEventId::cancel
()
96
{
97
scheduler::cancel
(m_event);
98
}
99
100
void
101
ScopedEventId::release
()
102
{
103
m_event.reset();
104
}
105
106
}
// namespace scheduler
107
}
// namespace nfd
nfd::scheduler::ScopedEventId::cancel
void cancel()
cancels the event manually
Definition:
scheduler.cpp:95
nfd::scheduler::ScopedEventId::operator=
ScopedEventId & operator=(const EventId &event)
assigns an event
Definition:
scheduler.cpp:80
nfd::scheduler::cancel
void cancel(const EventId &eventId)
cancel a scheduled event
Definition:
scheduler.cpp:53
nfd::scheduler::ScopedEventId::~ScopedEventId
~ScopedEventId()
cancels the event
Definition:
scheduler.cpp:89
ndn::util::scheduler::EventId
std::shared_ptr< ns3::EventId > EventId
Definition:
scheduler.hpp:39
nfd::scheduler::ScopedEventId::release
void release()
releases the event so that it won't be disconnected when this ScopedEventId is destructed ...
Definition:
scheduler.cpp:101
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
global-io.hpp
nfd::scheduler::resetGlobalScheduler
void resetGlobalScheduler()
Definition:
scheduler.cpp:59
nfd::scheduler::ScopedEventId
cancels an event automatically upon destruction
Definition:
scheduler.hpp:57
nfd::scheduler::ScopedEventId::ScopedEventId
ScopedEventId()
Definition:
scheduler.cpp:64
scheduler.hpp
nfd::scheduler::g_scheduler
static boost::thread_specific_ptr< Scheduler > g_scheduler
Definition:
scheduler.cpp:34
nfd::scheduler::schedule
EventId schedule(const time::nanoseconds &after, const Scheduler::Event &event)
schedule an event
Definition:
scheduler.cpp:47
nfd::scheduler::getGlobalScheduler
Scheduler & getGlobalScheduler()
Definition:
scheduler.cpp:37
ndnSIM
NFD
core
scheduler.cpp
Generated on Sat Nov 12 2016 16:02:53 for ndnSIM by
1.8.12