NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
scheduler.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#ifndef NDN_UTIL_SCHEDULER_HPP
23
#define NDN_UTIL_SCHEDULER_HPP
24
25
#include "../common.hpp"
26
#include "
monotonic_deadline_timer.hpp
"
27
28
#include "ns3/simulator.h"
29
30
#include <set>
31
32
namespace
ndn
{
33
namespace
util {
34
namespace
scheduler {
35
39
typedef
std::shared_ptr<ns3::EventId>
EventId
;
40
44
class
Scheduler
: noncopyable
45
{
46
public
:
50
typedef
function<void()>
Event
;
51
52
explicit
53
Scheduler
(boost::asio::io_service& ioService);
54
55
~Scheduler
();
56
61
EventId
62
scheduleEvent
(
const
time::nanoseconds& after,
const
Event& event);
63
67
void
68
cancelEvent
(
const
EventId& eventId);
69
73
void
74
cancelAllEvents
();
75
76
private
:
77
struct
EventInfo
78
{
79
EventInfo(
const
time::nanoseconds& after,
const
Event& event);
80
81
EventInfo(
const
time::steady_clock::TimePoint
& when,
const
EventInfo& previousEvent);
82
83
bool
84
operator <=
(
const
EventInfo& other)
const
85
{
86
return
this->m_scheduledTime <= other.m_scheduledTime;
87
}
88
89
bool
90
operator <
(
const
EventInfo& other)
const
91
{
92
return
this->m_scheduledTime < other.m_scheduledTime;
93
}
94
95
time::nanoseconds
96
expiresFromNow()
const
;
97
98
time::steady_clock::TimePoint
m_scheduledTime;
99
Event m_event;
100
mutable
EventId m_eventId;
101
};
102
103
typedef
std::multiset<EventId> EventQueue;
104
105
EventQueue m_events;
106
EventQueue::iterator
m_scheduledEvent;
107
};
108
109
}
// namespace scheduler
110
111
using
util::scheduler::Scheduler
;
112
113
}
// namespace util
114
115
// for backwards compatibility
116
using
util::scheduler::Scheduler
;
117
using
util::scheduler::EventId
;
118
119
}
// namespace ndn
120
121
#endif // NDN_UTIL_SCHEDULER_HPP
ndn::time::steady_clock::TimePoint
time_point TimePoint
Definition:
time.hpp:120
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::util::scheduler::Scheduler
Generic scheduler.
Definition:
scheduler.hpp:44
ndn::util::scheduler::Scheduler::Event
function< void()> Event
Definition:
scheduler.hpp:50
ndn::util::scheduler::Scheduler::scheduleEvent
EventId scheduleEvent(const time::nanoseconds &after, const Event &event)
Schedule a one-time event after the specified delay.
Definition:
scheduler.cpp:58
ndn::util::scheduler::Scheduler::cancelEvent
void cancelEvent(const EventId &eventId)
Cancel a scheduled event.
Definition:
scheduler.cpp:79
ndn::util::scheduler::Scheduler::cancelAllEvents
void cancelAllEvents()
Cancel all scheduled events.
Definition:
scheduler.cpp:89
nfd::cs::iterator
Table::const_iterator iterator
Definition:
cs-internal.hpp:41
ndn::util::scheduler::EventId
std::shared_ptr< ns3::EventId > EventId
Definition:
scheduler.hpp:39
ndn::util::scheduler::Scheduler::Scheduler
Scheduler(boost::asio::io_service &ioService)
Definition:
scheduler.cpp:47
ndn::util::scheduler::Scheduler::~Scheduler
~Scheduler()
Definition:
scheduler.cpp:52
ndn::operator<
constexpr bool operator<(const optional< T > &lhs, const optional< T > &rhs)
Definition:
backports-optional.hpp:267
ndn::operator<=
constexpr bool operator<=(const optional< T > &lhs, const optional< T > &rhs)
Definition:
backports-optional.hpp:274
monotonic_deadline_timer.hpp
ndnSIM
ndn-cxx
src
util
scheduler.hpp
Generated on Wed Jan 11 2017 18:17:15 for ndnSIM by
1.8.13