Skip to content

Commit

Permalink
fix LithiumServerTickScheduler fix TickEntry<T> field values not up-t…
Browse files Browse the repository at this point in the history
…o-date when reuse

just don't reuse
  • Loading branch information
Fallen-Breath committed Dec 3, 2024
1 parent 5a2e643 commit b28381e
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,27 @@ private List<NextTickListEntry<T>> collectTicks(MutableBoundingBox bounds, boole
* scheduled ticks which are set to execute at a different time.
*/
private void addScheduledTick(NextTickListEntry<T> tick) {
TickEntry<T> entry = this.scheduledTicks.computeIfAbsent(tick, this::createTickEntry);
// TISCM fix field value not up-to-date. see git history for yhe original lithium impl
TickEntry<T> oldEntry = this.scheduledTicks.get(tick);
if (oldEntry != null && oldEntry.scheduled)
{
// TISCM Micro Timing logger
this.scheduleSuccess = false;
return;
}

// TISCM Micro Timing logger
this.scheduleSuccess = !entry.scheduled;
this.scheduleSuccess = true;

if (!entry.scheduled) {
TickEntryQueue<T> timeIdx = this.scheduledTicksOrdered.computeIfAbsent(getBucketKey(tick.scheduledTime, tick.priority), key -> new TickEntryQueue<>());
timeIdx.push(entry);
TickEntry<T> entry = this.createTickEntry(tick);
this.scheduledTicks.put(tick, entry);

entry.scheduled = true;
}
// the entry is newly created, so the scheduled flag is always false

TickEntryQueue<T> timeIdx = this.scheduledTicksOrdered.computeIfAbsent(getBucketKey(tick.scheduledTime, tick.priority), key -> new TickEntryQueue<>());
timeIdx.push(entry);

entry.scheduled = true;
}

private TickEntry<T> createTickEntry(NextTickListEntry<T> tick) {
Expand Down

0 comments on commit b28381e

Please sign in to comment.