NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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; -*- */
2
/*
3
* Copyright (c) 2013-2018 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 "../net/asio-fwd.hpp"
27
28
#include <boost/system/error_code.hpp>
29
#include "../common.hpp"
30
31
#include "ns3/simulator.h"
32
33
#include <set>
34
#include <boost/asio/io_service.hpp>
35
#include <set>
36
37
namespace
ndn
{
38
namespace
util {
39
40
namespace
detail {
41
class
SteadyTimer;
42
}
// namespace detail
43
44
namespace
scheduler {
45
46
typedef
function<void()>
EventCallback
;
47
51
typedef
std::shared_ptr<ns3::EventId>
EventId
;
52
56
class
Scheduler
: noncopyable
57
{
58
public
:
62
typedef
EventCallback
Event
;
63
64
explicit
65
Scheduler
(
DummyIoService
& ioService);
66
67
~Scheduler
();
68
73
EventId
74
scheduleEvent
(
const
time::nanoseconds& after,
const
Event
& event);
75
79
void
80
cancelEvent
(
const
EventId
& eventId);
81
85
void
86
cancelAllEvents
();
87
88
private
:
89
struct
EventInfo
90
{
91
EventInfo(
const
time::nanoseconds& after,
const
Event
& event);
92
93
EventInfo(
const
time::steady_clock::TimePoint
& when,
const
EventInfo& previousEvent);
94
95
bool
96
operator <=
(
const
EventInfo& other)
const
97
{
98
return
this->m_scheduledTime <= other.m_scheduledTime;
99
}
100
101
bool
102
operator <
(
const
EventInfo& other)
const
103
{
104
return
this->m_scheduledTime < other.m_scheduledTime;
105
}
106
107
time::nanoseconds
108
expiresFromNow()
const
;
109
110
time::steady_clock::TimePoint
m_scheduledTime;
111
Event
m_event;
112
mutable
EventId
m_eventId;
113
};
114
115
typedef
std::multiset<EventId> EventQueue;
116
117
EventQueue m_events;
118
EventQueue::iterator
m_scheduledEvent;
119
};
120
121
}
// namespace scheduler
122
123
using
util::scheduler::Scheduler;
124
125
}
// namespace util
126
127
// for backwards compatibility
128
using
util::scheduler::Scheduler;
129
using
util::scheduler::EventId
;
130
131
}
// namespace ndn
132
133
#endif // NDN_UTIL_SCHEDULER_HPP
ndn::util::scheduler::EventCallback
function< void()> EventCallback
Definition:
scheduler.hpp:46
ndn::time::steady_clock::TimePoint
time_point TimePoint
Definition:
time.hpp:226
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:56
ndn::util::scheduler::Scheduler::Scheduler
Scheduler(DummyIoService &ioService)
Definition:
scheduler.cpp:49
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:60
ndn::operator<=
bool operator<=(const Delegation &lhs, const Delegation &rhs)
Definition:
delegation.cpp:43
ndn::util::scheduler::Scheduler::cancelEvent
void cancelEvent(const EventId &eventId)
Cancel a scheduled event.
Definition:
scheduler.cpp:81
ndn::util::scheduler::Scheduler::cancelAllEvents
void cancelAllEvents()
Cancel all scheduled events.
Definition:
scheduler.cpp:91
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:51
EventId
Opaque type (shared_ptr) representing ID of a scheduled event.
ndn::util::scheduler::Scheduler::~Scheduler
~Scheduler()
Definition:
scheduler.cpp:54
time.hpp
ndn::DummyIoService
Definition:
asio-fwd.hpp:27
ndn::util::scheduler::Scheduler::Event
EventCallback Event
Definition:
scheduler.hpp:62
ndn::operator<
bool operator<(const Delegation &lhs, const Delegation &rhs)
Definition:
delegation.cpp:36
ndnSIM
ndn-cxx
src
util
scheduler.hpp
Generated on Tue Aug 7 2018 16:19:17 for ndnSIM by
1.8.14