Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
3c614480
Commit
3c614480
authored
Jan 28, 2016
by
Björn Richerzhagen
Browse files
Scheduler: ensure correct order of scheduleImmediately()-events
parent
2df7fcd8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/simengine/Scheduler.java
View file @
3c614480
...
...
@@ -494,6 +494,10 @@ public class Scheduler implements EventHandler,
protected
final
Object
data
;
protected
long
simTime
;
protected
long
globalOrderIdx
;
protected
static
long
globalOrderCounter
=
0
;
protected
SchedulerEvent
(
Object
data
,
long
simTime
,
EventHandler
handler
,
int
type
)
{
...
...
@@ -507,6 +511,7 @@ public class Scheduler implements EventHandler,
this
.
handler
=
handler
;
this
.
simTime
=
simTime
;
this
.
type
=
type
;
this
.
globalOrderIdx
=
++
globalOrderCounter
;
}
public
long
getSimulationTime
()
{
...
...
@@ -514,7 +519,8 @@ public class Scheduler implements EventHandler,
}
public
int
compareTo
(
SchedulerEvent
o
)
{
return
Double
.
compare
(
this
.
simTime
,
o
.
simTime
);
int
comp
=
Double
.
compare
(
this
.
simTime
,
o
.
simTime
);
return
comp
==
0
?
Double
.
compare
(
this
.
globalOrderIdx
,
o
.
globalOrderIdx
)
:
comp
;
}
}
...
...
@@ -595,11 +601,8 @@ public class Scheduler implements EventHandler,
@Override
public
int
compare
(
SchedulerEvent
o1
,
SchedulerEvent
o2
)
{
if
(
o1
.
getSimulationTime
()
>
o2
.
getSimulationTime
())
{
return
1
;
}
else
{
return
-
1
;
}
int
comp
=
Double
.
compare
(
o1
.
simTime
,
o2
.
simTime
);
return
(
comp
==
0
?
Double
.
compare
(
o1
.
globalOrderIdx
,
o2
.
globalOrderIdx
)
:
comp
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment