We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 65e92d5 commit c8eb15cCopy full SHA for c8eb15c
lib/shared/common/src/main/java/com/launchdarkly/sdk/collections/IterableAsyncQueue.java
@@ -37,14 +37,18 @@ class IterableAsyncQueue<T> {
37
* @param item the item to add (maybe null)
38
*/
39
public void put(T item) {
40
+ CompletableFuture<T> pendingFuture = null;
41
synchronized (lock) {
42
CompletableFuture<T> nextFuture = pendingFutures.pollFirst();
43
if(nextFuture != null) {
- nextFuture.complete(item);
44
+ pendingFuture = nextFuture;
45
+ } else {
46
+ queue.addLast(item);
47
return;
48
}
- queue.addLast(item);
49
50
+ // Execute callback outside the lock.
51
+ pendingFuture.complete(item);
52
53
/**
54
* Retrieves and removes an item from the queue, returning a future that completes with the item.
0 commit comments