Package com.hazelcast.collection
Interface BaseQueue<E>
- Type Parameters:
E
- queue item type
- All Superinterfaces:
DistributedObject
- All Known Subinterfaces:
IQueue<E>
,TransactionalQueue<E>
Base interface for Hazelcast distributed queues.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.boolean
Inserts the specified element into this queue, waiting up to the specified wait time if necessary for space to become available.poll()
Retrieves and removes the head of this queue, or returnsnull
if this queue is empty.Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.int
size()
Returns the number of elements in this collection.take()
Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getDestroyContextForTenant, getName, getPartitionKey, getServiceName
-
Method Details
-
offer
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. Returnstrue
upon success andfalse
if no space is currently available.- Parameters:
e
- the element to add- Returns:
true
if the element was added to this queue,false
otherwise
-
offer
Inserts the specified element into this queue, waiting up to the specified wait time if necessary for space to become available.- Parameters:
e
- the element to addtimeout
- how long to wait before giving up, in units ofunit
unit
- aTimeUnit
determines how to interpret thetimeout
parameter- Returns:
true
if successful, orfalse
if the specified waiting time elapses before space is available- Throws:
InterruptedException
- if interrupted while waiting
-
take
Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.- Returns:
- the head of this queue
- Throws:
InterruptedException
- if interrupted while waiting
-
poll
E poll()Retrieves and removes the head of this queue, or returnsnull
if this queue is empty.- Returns:
- the head of this queue, or
null
if this queue is empty
-
poll
Retrieves and removes the head of this queue, 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 - Throws:
InterruptedException
- if interrupted while waiting
-
size
int size()Returns the number of elements in this collection. If this collection contains more thanInteger.MAX_VALUE
elements, returnsInteger.MAX_VALUE
.- Returns:
- the number of elements in this collection
-