A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
event-garbage-collector.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007 INESC Porto
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
7
*/
8
#ifndef EVENT_GARBAGE_COLLECTOR_H
9
#define EVENT_GARBAGE_COLLECTOR_H
10
11
#include "ns3/event-id.h"
12
#include "ns3/simulator.h"
13
14
#include <set>
15
16
/**
17
* \file
18
* \ingroup events
19
* \ingroup core-helpers
20
* ns3::EventGarbageCollector declaration.
21
*/
22
23
namespace
ns3
24
{
25
26
/**
27
* \ingroup events
28
* \ingroup core-helpers
29
*
30
* \brief An object that tracks scheduled events and automatically
31
* cancels them when it is destroyed. It is useful in situations
32
* where multiple instances of the same type of event can
33
* simultaneously be scheduled, and when the events should be limited
34
* to the lifetime of a container object.
35
*/
36
class
EventGarbageCollector
37
{
38
public
:
39
EventGarbageCollector
();
40
41
/**
42
* \brief Tracks a new event
43
* \param [in] event the Event to track
44
*/
45
void
Track
(
EventId
event);
46
47
~EventGarbageCollector
();
48
49
private
:
50
/** Event list container */
51
typedef
std::multiset<EventId>
EventList
;
52
53
/** Initial threshold for cleaning the event list. */
54
const
typename
EventList::size_type
CHUNK_INIT_SIZE
= 8;
55
/**
56
* Threshold to switch from exponential to linear growth
57
* in the cleanup frequency.
58
*/
59
const
typename
EventList::size_type
CHUNK_MAX_SIZE
= 128;
60
61
EventList::size_type
m_nextCleanupSize
;
//!< Batch size for cleanup
62
EventList
m_events
;
//!< The tracked event list
63
64
/**
65
* \brief Called when a new event was added and the cleanup limit was
66
* exceeded in consequence.
67
*/
68
void
Cleanup
();
69
/**
70
* \brief Grow the cleanup limit.
71
* Increase the cleanup size by the smaller of
72
* the current cleanup size (exponential growth),
73
* or the CHUNK_MAX_SIZE (linear growth).
74
*/
75
void
Grow
();
76
/**
77
* \brief Shrink the cleanup limit
78
* Reduce the cleanup size by factors of two until less than the
79
* current event list, then Grow one step.
80
*/
81
void
Shrink
();
82
};
83
84
}
// namespace ns3
85
86
#endif
/* EVENT_GARBAGE_COLLECTOR_H */
ns3::EventGarbageCollector
An object that tracks scheduled events and automatically cancels them when it is destroyed.
Definition
event-garbage-collector.h:37
ns3::EventGarbageCollector::CHUNK_INIT_SIZE
const EventList::size_type CHUNK_INIT_SIZE
Initial threshold for cleaning the event list.
Definition
event-garbage-collector.h:54
ns3::EventGarbageCollector::Track
void Track(EventId event)
Tracks a new event.
Definition
event-garbage-collector.cc:27
ns3::EventGarbageCollector::CHUNK_MAX_SIZE
const EventList::size_type CHUNK_MAX_SIZE
Threshold to switch from exponential to linear growth in the cleanup frequency.
Definition
event-garbage-collector.h:59
ns3::EventGarbageCollector::m_events
EventList m_events
The tracked event list.
Definition
event-garbage-collector.h:62
ns3::EventGarbageCollector::Cleanup
void Cleanup()
Called when a new event was added and the cleanup limit was exceeded in consequence.
Definition
event-garbage-collector.cc:55
ns3::EventGarbageCollector::m_nextCleanupSize
EventList::size_type m_nextCleanupSize
Batch size for cleanup.
Definition
event-garbage-collector.h:61
ns3::EventGarbageCollector::Grow
void Grow()
Grow the cleanup limit.
Definition
event-garbage-collector.cc:37
ns3::EventGarbageCollector::~EventGarbageCollector
~EventGarbageCollector()
Definition
event-garbage-collector.cc:80
ns3::EventGarbageCollector::Shrink
void Shrink()
Shrink the cleanup limit Reduce the cleanup size by factors of two until less than the current event ...
Definition
event-garbage-collector.cc:43
ns3::EventGarbageCollector::EventGarbageCollector
EventGarbageCollector()
Definition
event-garbage-collector.cc:20
ns3::EventGarbageCollector::EventList
std::multiset< EventId > EventList
Event list container.
Definition
event-garbage-collector.h:51
ns3::EventId
An identifier for simulation events.
Definition
event-id.h:45
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
core
helper
event-garbage-collector.h
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0