Package org.redisson.api
Interface RBlockingQueueAsync<V>
-
- Type Parameters:
V
- the type of elements held in this collection
- All Superinterfaces:
RCollectionAsync<V>
,RExpirableAsync
,RObjectAsync
,RQueueAsync<V>
- All Known Subinterfaces:
RBlockingDeque<V>
,RBlockingDequeAsync<V>
,RBlockingQueue<V>
,RBoundedBlockingQueue<V>
,RBoundedBlockingQueueAsync<V>
,RPriorityBlockingDeque<V>
,RPriorityBlockingQueue<V>
,RTransferQueue<V>
,RTransferQueueAsync<V>
- All Known Implementing Classes:
RedissonBlockingDeque
,RedissonBlockingQueue
,RedissonBoundedBlockingQueue
,RedissonPriorityBlockingDeque
,RedissonPriorityBlockingQueue
,RedissonTransferQueue
public interface RBlockingQueueAsync<V> extends RQueueAsync<V>
Distributed async implementation ofBlockingQueue
- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RFuture<Integer>
drainToAsync(Collection<? super V> c)
Removes all available elements from this queue and adds them to the given collection in async mode.RFuture<Integer>
drainToAsync(Collection<? super V> c, int maxElements)
Removes at most the given number of available elements from this queue and adds them to the given collection in async mode.RFuture<V>
pollAsync(long timeout, TimeUnit unit)
Retrieves and removes the head of this queue in async mode, waiting up to the specified wait time if necessary for an element to become available.RFuture<V>
pollFromAnyAsync(long timeout, TimeUnit unit, String... queueNames)
Retrieves and removes first available head element of any queue in async mode, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.RFuture<V>
pollLastAndOfferFirstToAsync(String queueName, long timeout, TimeUnit unit)
Retrieves and removes last available tail element of this queue and adds it at the head ofqueueName
, waiting up to the specified wait time if necessary for an element to become available.RFuture<Void>
putAsync(V e)
Inserts the specified element into this queue in async mode, waiting if necessary for space to become available.RFuture<V>
takeAsync()
Retrieves and removes the head of this queue in async mode, waiting if necessary until an element becomes available.RFuture<V>
takeLastAndOfferFirstToAsync(String queueName)
Retrieves and removes last available tail element of any queue and adds it at the head ofqueueName
, waiting if necessary for an element to become available in any of defined queues including queue itself.-
Methods inherited from interface org.redisson.api.RCollectionAsync
addAllAsync, addAsync, containsAllAsync, containsAsync, removeAllAsync, removeAsync, retainAllAsync, sizeAsync
-
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RObjectAsync
copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
Methods inherited from interface org.redisson.api.RQueueAsync
addListenerAsync, offerAsync, peekAsync, pollAsync, pollAsync, pollLastAndOfferFirstToAsync, readAllAsync
-
-
-
-
Method Detail
-
pollFromAnyAsync
RFuture<V> pollFromAnyAsync(long timeout, TimeUnit unit, String... queueNames)
Retrieves and removes first available head element of any queue in async mode, waiting up to the specified wait time if necessary for an element to become available in any of defined queues including queue itself.- Parameters:
queueNames
- - queue names. Queue name itself is always includedtimeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- Future object with the head of this queue, or
null
if the specified waiting time elapses before an element is available
-
drainToAsync
RFuture<Integer> drainToAsync(Collection<? super V> c, int maxElements)
Removes at most the given number of available elements from this queue and adds them to the given collection in async mode. A failure encountered while attempting to add elements to collectionc
may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result inIllegalArgumentException
. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.- Parameters:
c
- the collection to transfer elements intomaxElements
- the maximum number of elements to transfer- Returns:
- the number of elements transferred
- Throws:
UnsupportedOperationException
- if addition of elements is not supported by the specified collectionClassCastException
- if the class of an element of this queue prevents it from being added to the specified collectionNullPointerException
- if the specified collection is nullIllegalArgumentException
- if the specified collection is this queue, or some property of an element of this queue prevents it from being added to the specified collection
-
drainToAsync
RFuture<Integer> drainToAsync(Collection<? super V> c)
Removes all available elements from this queue and adds them to the given collection in async mode. This operation may be more efficient than repeatedly polling this queue. A failure encountered while attempting to add elements to collectionc
may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result inIllegalArgumentException
. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.- Parameters:
c
- the collection to transfer elements into- Returns:
- the number of elements transferred
- Throws:
UnsupportedOperationException
- if addition of elements is not supported by the specified collectionClassCastException
- if the class of an element of this queue prevents it from being added to the specified collectionNullPointerException
- if the specified collection is nullIllegalArgumentException
- if the specified collection is this queue, or some property of an element of this queue prevents it from being added to the specified collection
-
pollLastAndOfferFirstToAsync
RFuture<V> pollLastAndOfferFirstToAsync(String queueName, long timeout, TimeUnit unit)
Retrieves and removes last available tail element of this queue and adds it at the head ofqueueName
, waiting up to the specified wait time if necessary for an element to become available.- Parameters:
queueName
- - names of destination queuetimeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the tail of this queue, or
null
if the specified waiting time elapses before an element is available
-
takeLastAndOfferFirstToAsync
RFuture<V> takeLastAndOfferFirstToAsync(String queueName)
Retrieves and removes last available tail element of any queue and adds it at the head ofqueueName
, waiting if necessary for an element to become available in any of defined queues including queue itself.- Parameters:
queueName
- - names of destination queue- Returns:
- the tail of this queue, or
null
if the specified waiting time elapses before an element is available
-
pollAsync
RFuture<V> pollAsync(long timeout, TimeUnit unit)
Retrieves and removes the head of this queue in async mode, waiting up to the specified wait time if necessary for an element to become available.- Parameters:
timeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the head of this queue, or
null
if the specified waiting time elapses before an element is available
-
takeAsync
RFuture<V> takeAsync()
Retrieves and removes the head of this queue in async mode, waiting if necessary until an element becomes available.- Returns:
- the head of this queue
-
putAsync
RFuture<Void> putAsync(V e)
Inserts the specified element into this queue in async mode, waiting if necessary for space to become available.- Parameters:
e
- the element to add- Returns:
- void
- Throws:
ClassCastException
- if the class of the specified element prevents it from being added to this queueNullPointerException
- if the specified element is nullIllegalArgumentException
- if some property of the specified element prevents it from being added to this queue
-
-