// Artificial deadlock due to delayed processes.
// Advance time to next possible time.
synchronized (this) {
if (!_eventQueue.isEmpty()) {
//Take the first time-blocked process from the queue.
TimedEvent event = (TimedEvent) _eventQueue.take();
//Advance time to the resumption time of this process.
setModelTime(event.timeStamp);
_informOfDelayUnblock();
} else {
throw new InternalErrorException("Inconsistency"
+ " in number of actors blocked on delays count"
+ " and the entries in the CalendarQueue");
}
//Remove any other process waiting to be resumed at the new
//advanced time (the new currentTime).
boolean sameTime = true;
while (sameTime) {
//If queue is not empty, then determine the resumption
//time of the next process.
if (!_eventQueue.isEmpty()) {
//Remove the first process from the queue.
TimedEvent event = (TimedEvent) _eventQueue.take();
Actor actor = (Actor) event.contents;
//Get the resumption time of the newly removed
//process.
Time newTime = event.timeStamp;
//If the resumption time of the newly removed
//process is the same as the newly advanced time
//then unblock it. Else put the newly removed
//process back on the event queue.
if (newTime.equals(getModelTime())) {
_informOfDelayUnblock();
} else {
_eventQueue.put(new TimedEvent(newTime, actor));
sameTime = false;
}
} else {
sameTime = false;
}