author | Tom Henderson <tomh@tomh.org> |
Sat, 16 Jan 2016 08:14:40 -0800 | |
changeset 11683 | 9142266fbb25 |
parent 11131 | 6a448ac28669 |
permissions | -rw-r--r-- |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005 INRIA |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#include "event-id.h" |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#include "simulator.h" |
472
41aa5fca4f49
make sure that Simulator::Cancel deals correctly with events which were already scheduled
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
22 |
#include "event-impl.h" |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
23 |
#include "log.h" |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
24 |
|
11095
be1aa0c5ac72
[Doxygen] Events.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
25 |
/** |
be1aa0c5ac72
[Doxygen] Events.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
26 |
* \file |
be1aa0c5ac72
[Doxygen] Events.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
27 |
* \ingroup events |
11131
6a448ac28669
[Doxygen] Various in src/core
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11095
diff
changeset
|
28 |
* ns3::EventId implementation. |
11095
be1aa0c5ac72
[Doxygen] Events.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
29 |
*/ |
be1aa0c5ac72
[Doxygen] Events.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
30 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9193
diff
changeset
|
31 |
namespace ns3 { |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9193
diff
changeset
|
33 |
NS_LOG_COMPONENT_DEFINE ("EventId"); |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
EventId::EventId () |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
36 |
: m_eventImpl (0), |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
472
diff
changeset
|
37 |
m_ts (0), |
5521
37c6c83d4252
Introduce Simulator::ScheduleWithContext* and Simulator::GetContext
Guillaume Seguin <guillaume@segu.in>
parents:
1696
diff
changeset
|
38 |
m_context (0), |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
39 |
m_uid (0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
40 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
41 |
NS_LOG_FUNCTION (this); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
42 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
43 |
|
5521
37c6c83d4252
Introduce Simulator::ScheduleWithContext* and Simulator::GetContext
Guillaume Seguin <guillaume@segu.in>
parents:
1696
diff
changeset
|
44 |
EventId::EventId (const Ptr<EventImpl> &impl, uint64_t ts, uint32_t context, uint32_t uid) |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
45 |
: m_eventImpl (impl), |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
472
diff
changeset
|
46 |
m_ts (ts), |
5521
37c6c83d4252
Introduce Simulator::ScheduleWithContext* and Simulator::GetContext
Guillaume Seguin <guillaume@segu.in>
parents:
1696
diff
changeset
|
47 |
m_context (context), |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
48 |
m_uid (uid) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
49 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
50 |
NS_LOG_FUNCTION (this << impl << ts << context << uid); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
51 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
52 |
void |
122
6b8f1eda5c57
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
110
diff
changeset
|
53 |
EventId::Cancel (void) |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
54 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
55 |
NS_LOG_FUNCTION (this); |
1008
6f2ea723a1db
use a Ptr<> to manage EventImpl instances
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1005
diff
changeset
|
56 |
Simulator::Cancel (*this); |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
} |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
58 |
bool |
981
eda90b17fc05
EvenId const fixes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
962
diff
changeset
|
59 |
EventId::IsExpired (void) const |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
60 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
61 |
NS_LOG_FUNCTION (this); |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
62 |
return Simulator::IsExpired (*this); |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
63 |
} |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6821
diff
changeset
|
64 |
bool |
981
eda90b17fc05
EvenId const fixes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
962
diff
changeset
|
65 |
EventId::IsRunning (void) const |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
66 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
67 |
NS_LOG_FUNCTION (this); |
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
68 |
return !IsExpired (); |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
150
diff
changeset
|
69 |
} |
1009
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
70 |
EventImpl * |
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
71 |
EventId::PeekEventImpl (void) const |
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
72 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
73 |
NS_LOG_FUNCTION (this); |
1009
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
74 |
return PeekPointer (m_eventImpl); |
adc3ac9baea8
optimize EventImpl refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1008
diff
changeset
|
75 |
} |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
76 |
uint64_t |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
472
diff
changeset
|
77 |
EventId::GetTs (void) const |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
79 |
NS_LOG_FUNCTION (this); |
675
a5878de7d71c
The header file ns3/cairo-wideint-private.h was added since the type int32_t was used.
Emmanuelle Laprise
parents:
472
diff
changeset
|
80 |
return m_ts; |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
81 |
} |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
82 |
uint32_t |
5521
37c6c83d4252
Introduce Simulator::ScheduleWithContext* and Simulator::GetContext
Guillaume Seguin <guillaume@segu.in>
parents:
1696
diff
changeset
|
83 |
EventId::GetContext (void) const |
37c6c83d4252
Introduce Simulator::ScheduleWithContext* and Simulator::GetContext
Guillaume Seguin <guillaume@segu.in>
parents:
1696
diff
changeset
|
84 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
85 |
NS_LOG_FUNCTION (this); |
5521
37c6c83d4252
Introduce Simulator::ScheduleWithContext* and Simulator::GetContext
Guillaume Seguin <guillaume@segu.in>
parents:
1696
diff
changeset
|
86 |
return m_context; |
37c6c83d4252
Introduce Simulator::ScheduleWithContext* and Simulator::GetContext
Guillaume Seguin <guillaume@segu.in>
parents:
1696
diff
changeset
|
87 |
} |
37c6c83d4252
Introduce Simulator::ScheduleWithContext* and Simulator::GetContext
Guillaume Seguin <guillaume@segu.in>
parents:
1696
diff
changeset
|
88 |
uint32_t |
122
6b8f1eda5c57
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
110
diff
changeset
|
89 |
EventId::GetUid (void) const |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
90 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
91 |
NS_LOG_FUNCTION (this); |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
92 |
return m_uid; |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
93 |
} |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
94 |
|
962
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
95 |
bool operator == (const EventId &a, const EventId &b) |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
96 |
{ |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
97 |
return |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
98 |
a.m_uid == b.m_uid && |
5521
37c6c83d4252
Introduce Simulator::ScheduleWithContext* and Simulator::GetContext
Guillaume Seguin <guillaume@segu.in>
parents:
1696
diff
changeset
|
99 |
a.m_context == b.m_context && |
962
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
100 |
a.m_ts == b.m_ts && |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
101 |
a.m_eventImpl == b.m_eventImpl; |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
102 |
} |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
103 |
bool operator != (const EventId &a, const EventId &b) |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
104 |
{ |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
105 |
return !(a == b); |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
106 |
} |
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
107 |
|
473a781ec774
add operator == and != t o EventId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
927
diff
changeset
|
108 |
|
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
109 |
|
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents:
7169
diff
changeset
|
110 |
} // namespace ns3 |