Utils: slightly faster add in HashSetDelayedBlockingQueue

This commit is contained in:
2025-04-29 12:40:45 +02:00
parent 7aa968a569
commit 1b19c77bb6

View File

@@ -34,11 +34,9 @@ public class HashSetDelayedBlockingQueue<T> {
synchronized (this) {
if (_closed) throw new IllegalStateException("Adding to a queue that is closed!");
if (_set.containsKey(el))
if (_set.putIfAbsent(el, new SetElement<>(el, System.currentTimeMillis())) != null)
return false;
_set.put(el, new SetElement<>(el, System.currentTimeMillis()));
this.notify();
return true;
}