Skip to content

Commit

Permalink
ARTEMIS-4569 Improving order in which the list is added versus cancel…
Browse files Browse the repository at this point in the history
… call

I just did some static analysis of this code, and I believe it would be better to first add to the list
before setting the cancel task.

Reason for that is in case the Runnable is dequeued between the add in the deQueue and setting the cancel task.

Possibility is remote but my OCD wouldn't let me ignore this small possibility.
  • Loading branch information
clebertsuconic committed Jan 18, 2024
1 parent 22a31fb commit 2760a3e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,8 @@ public boolean checkMemory(final Runnable runWhenAvailable, Consumer<AtomicRunna
}

private void addToBlockList(AtomicRunnable atomicRunnable, Consumer<AtomicRunnable> accepted) {
onMemoryFreedRunnables.add(atomicRunnable);
atomicRunnable.setCancel(onMemoryFreedRunnables::remove);
onMemoryFreedRunnables.add(atomicRunnable);
if (accepted != null) {
accepted.accept(atomicRunnable);
}
Expand Down

0 comments on commit 2760a3e

Please sign in to comment.