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
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
36
struct
EventIdImpl;
37
41
typedef
std::shared_ptr<ns3::EventId>
EventId
;
42
46
class
Scheduler
47
{
48
public
:
49
typedef
function<void()>
Event
;
50
51
Scheduler
(boost::asio::io_service& ioService);
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
friend
struct
EventIdImpl
;
101
102
EventQueue m_events;
103
EventQueue::iterator
m_scheduledEvent;
104
};
105
106
}
// namespace scheduler
107
108
using
util::scheduler::Scheduler
;
109
110
}
// namespace util
111
112
// for backwards compatibility
113
using
util::scheduler::Scheduler
;
114
using
util::scheduler::EventId
;
115
116
}
// namespace ndn
117
118
#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:46
ndn::util::scheduler::Scheduler::Event
function< void()> Event
Definition:
scheduler.hpp:49
ndn::util::scheduler::EventIdImpl
Definition:
scheduler.cpp:48
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:117
ndn::util::scheduler::Scheduler::cancelEvent
void cancelEvent(const EventId &eventId)
Cancel scheduled event.
Definition:
scheduler.cpp:128
ndn::util::scheduler::Scheduler::cancelAllEvents
void cancelAllEvents()
Cancel all scheduled events.
Definition:
scheduler.cpp:138
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:41
ndn::util::scheduler::Scheduler::Scheduler
Scheduler(boost::asio::io_service &ioService)
Definition:
scheduler.cpp:111
monotonic_deadline_timer.hpp
ndnSIM
ndn-cxx
src
util
scheduler.hpp
Generated on Tue Feb 23 2016 22:18:44 for ndnSIM by
1.8.11