Class LoomQueue<E>
Supports bounded and unbounded offer/poll/drain operations in both synchronous and
asynchronous variants. Large bulk operations are split into server-sized chunks automatically.
Obtain instances via LoomClient.getQueue or LoomCache.getQueue; handles are
thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptiondrain()intdrainTo(Collection<? super E> target) intdrainTo(Collection<? super E> target, int maxElements) drainToAsync(Collection<? super E> target, int maxElements) booleanintofferAll(Collection<? extends E> items) offerAllAsync(Collection<? extends E> items) offerAsync(E item) @Nullable Epeek()CompletableFuture<@Nullable E> @Nullable Epoll()poll(int count) @Nullable ERemoves and returns the head element, blocking up totimeoutfor one to become available; returnsnullif the timeout elapses first.CompletableFuture<@Nullable E> pollAsync(int count) intsize()take()Removes and returns the head element, blocking until one becomes available.
-
Method Details
-
offer
-
poll
-
take
Removes and returns the head element, blocking until one becomes available.LoomCache replicates queue mutations through Raft, and the deterministic apply path must never block, so this is implemented as a bounded client-side poll loop with exponential backoff rather than a server-side park. Semantically it matches a blocking take: it returns only once an element has been removed for this caller, or throws if the calling thread is interrupted. Each underlying poll is an ordinary replicated dequeue.
- Returns:
- the head element (never
null) - Throws:
InterruptedException- if the calling thread is interrupted while waiting
-
poll
Removes and returns the head element, blocking up totimeoutfor one to become available; returnsnullif the timeout elapses first.See
take()for why this is a client-side backoff poll loop rather than a server-side wait.- Parameters:
timeout- maximum time to wait; must be non-null and non-negative- Returns:
- the head element, or
nullif the timeout elapsed - Throws:
InterruptedException- if the calling thread is interrupted while waiting
-
peek
-
size
public int size() -
offerAll
-
poll
-
drain
-
drainTo
-
drainTo
-
offerAsync
-
pollAsync
-
peekAsync
-
sizeAsync
-
offerAllAsync
-
pollAsync
-
drainAsync
-
drainToAsync
-