NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
2
/*
3
* Copyright (c) 2013-2017 Regents of the University of California.
4
*
5
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6
*
7
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU Lesser General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later version.
10
*
11
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14
*
15
* You should have received copies of the GNU General Public License and GNU Lesser
16
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17
* <http://www.gnu.org/licenses/>.
18
*
19
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20
*/
21
22
#ifndef NDN_UTIL_SCHEDULER_HPP
23
#define NDN_UTIL_SCHEDULER_HPP
24
25
#include "
time.hpp
"
26
#include "../common.hpp"
27
28
#include "ns3/simulator.h"
29
30
#include <set>
31
#include <boost/asio/io_service.hpp>
32
#include <set>
33
34
namespace
ndn
{
35
namespace
util {
36
37
namespace
detail {
38
class
MonotonicDeadlineTimer;
39
}
// namespace detail
40
41
namespace
scheduler {
42
43
typedef
function<void()>
EventCallback
;
44
48
typedef
std::shared_ptr<ns3::EventId>
EventId
;
49
53
class
Scheduler
: noncopyable
54
{
55
public
:
59
typedef
EventCallback
Event
;
60
61
explicit
62
Scheduler
(boost::asio::io_service& ioService);
63
64
~
Scheduler
();
65
70
EventId
71
scheduleEvent(
const
time::nanoseconds& after,
const
Event& event);
72
76
void
77
cancelEvent(
const
EventId& eventId);
78
82
void
83
cancelAllEvents();
84
85
private
:
86
struct
EventInfo
87
{
88
EventInfo(
const
time::nanoseconds& after,
const
Event& event);
89
90
EventInfo(
const
time::steady_clock::TimePoint
& when,
const
EventInfo& previousEvent);
91
92
bool
93
operator <=
(
const
EventInfo& other)
const
94
{
95
return
this->m_scheduledTime <= other.m_scheduledTime;
96
}
97
98
bool
99
operator <
(
const
EventInfo& other)
const
100
{
101
return
this->m_scheduledTime < other.m_scheduledTime;
102
}
103
104
time::nanoseconds
105
expiresFromNow()
const
;
106
107
time::steady_clock::TimePoint
m_scheduledTime;
108
Event m_event;
109
mutable
EventId m_eventId;
110
};
111
112
typedef
std::multiset<EventId> EventQueue;
113
114
EventQueue m_events;
115
EventQueue::iterator
m_scheduledEvent;
116
};
117
118
}
// namespace scheduler
119
120
using
util::scheduler::Scheduler
;
121
122
}
// namespace util
123
124
// for backwards compatibility
125
using
util::scheduler::Scheduler
;
126
using
util::scheduler::EventId
;
127
128
}
// namespace ndn
129
130
#endif // NDN_UTIL_SCHEDULER_HPP
ndn::util::scheduler::EventCallback
function< void()> EventCallback
Definition:
scheduler.hpp:43
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:53
ndn::operator<=
bool operator<=(const Delegation &lhs, const Delegation &rhs)
Definition:
delegation.cpp:43
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:48
time.hpp
ndn::util::scheduler::Scheduler::Event
EventCallback Event
Definition:
scheduler.hpp:59
ndn::operator<
bool operator<(const Delegation &lhs, const Delegation &rhs)
Definition:
delegation.cpp:36
ndnSIM
ndn-cxx
src
util
scheduler.hpp
Generated on Thu Nov 2 2017 03:30:29 for ndnSIM by
1.8.11