NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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
45
{
46
public
:
47
typedef
function<void()>
Event
;
48
49
Scheduler
(boost::asio::io_service& ioService);
50
51
~Scheduler
();
52
57
EventId
58
scheduleEvent
(
const
time::nanoseconds& after,
const
Event& event);
59
63
void
64
cancelEvent
(
const
EventId& eventId);
65
69
void
70
cancelAllEvents
();
71
72
private
:
73
struct
EventInfo
74
{
75
EventInfo(
const
time::nanoseconds& after,
const
Event& event);
76
77
EventInfo(
const
time::steady_clock::TimePoint
& when,
const
EventInfo& previousEvent);
78
79
bool
80
operator <=(
const
EventInfo& other)
const
81
{
82
return
this->m_scheduledTime <= other.m_scheduledTime;
83
}
84
85
bool
86
operator <(
const
EventInfo& other)
const
87
{
88
return
this->m_scheduledTime < other.m_scheduledTime;
89
}
90
91
time::nanoseconds
92
expiresFromNow()
const
;
93
94
time::steady_clock::TimePoint
m_scheduledTime;
95
Event m_event;
96
mutable
EventId m_eventId;
97
};
98
99
typedef
std::multiset<EventId> EventQueue;
100
101
EventQueue m_events;
102
EventQueue::iterator
m_scheduledEvent;
103
};
104
105
}
// namespace scheduler
106
107
using
util::scheduler::Scheduler
;
108
109
}
// namespace util
110
111
// for backwards compatibility
112
using
util::scheduler::Scheduler
;
113
using
util::scheduler::EventId
;
114
115
}
// namespace ndn
116
117
#endif // NDN_UTIL_SCHEDULER_HPP
ndn::time::steady_clock::TimePoint
time_point TimePoint
Definition:
time.hpp:108
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:47
ndn::util::scheduler::Scheduler::scheduleEvent
EventId scheduleEvent(const time::nanoseconds &after, const Event &event)
Schedule one time event after the specified delay.
Definition:
scheduler.cpp:85
ndn::util::scheduler::Scheduler::cancelEvent
void cancelEvent(const EventId &eventId)
Cancel scheduled event.
Definition:
scheduler.cpp:106
ndn::util::scheduler::Scheduler::cancelAllEvents
void cancelAllEvents()
Cancel all scheduled events.
Definition:
scheduler.cpp:116
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:74
ndn::util::scheduler::Scheduler::~Scheduler
~Scheduler()
Definition:
scheduler.cpp:79
monotonic_deadline_timer.hpp
ndnSIM
ndn-cxx
src
util
scheduler.hpp
Generated on Sat Nov 12 2016 16:02:53 for ndnSIM by
1.8.12