18 #ifndef _DECAF_UTIL_CONCURRENT_SYNCHRONOUSQUEUE_H_
19 #define _DECAF_UTIL_CONCURRENT_SYNCHRONOUSQUEUE_H_
29 namespace concurrent {
63 template<
typename E >
67 class EmptyIterator :
public Iterator<E> {
73 "Cannot traverse a Synchronous Queue.");
76 virtual bool hasNext()
const {
80 virtual void remove() {
83 "No Elements to remove from a Synchronous Queue.");
218 if ((
void*) &value ==
this) {
226 return new EmptyIterator();
230 return new EmptyIterator();
272 return std::vector<E>();
277 if ((
void*) &c ==
this) {
280 "Cannot drain a Collection to Itself.");
286 while ((
poll(element)) !=
false) {
296 if ((
void*) &c ==
this) {
299 "Cannot drain a Collection to Itself.");
305 while (count < maxElements && (
poll(element) !=
false)) {
The root interface in the collection hierarchy.
Definition: Collection.h:68
A decaf::util::Queue that additionally supports operations that wait for the queue to become non-empt...
Definition: BlockingQueue.h:164
virtual bool retainAll(const Collection< E > &collection DECAF_UNUSED)
Definition: SynchronousQueue.h:263
SynchronousQueue()
Definition: SynchronousQueue.h:94
virtual bool isEmpty() const =0
virtual void put(const E &value DECAF_UNUSED)
Adds the specified element to this queue, waiting if necessary for another thread to receive it...
Definition: SynchronousQueue.h:108
virtual bool isEmpty() const
Returns true if this collection contains no elements.
Definition: SynchronousQueue.h:233
virtual bool poll(E &result DECAF_UNUSED, long long timeout DECAF_UNUSED, const TimeUnit &unit DECAF_UNUSED)
Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time...
Definition: SynchronousQueue.h:193
Defines an object that can be used to iterate over the elements of a collection.
Definition: Iterator.h:34
A TimeUnit represents time durations at a given unit of granularity and provides utility methods to c...
Definition: TimeUnit.h:62
virtual int remainingCapacity() const
Returns the number of additional elements that this queue can ideally (in the absence of memory or re...
Definition: SynchronousQueue.h:241
virtual bool peek(E &result DECAF_UNUSED) const
Definition: SynchronousQueue.h:267
virtual bool offer(const E &e DECAF_UNUSED, long long timeout DECAF_UNUSED, const TimeUnit &unit DECAF_UNUSED)
Inserts the specified element into this queue, waiting if necessary up to the specified wait time for...
Definition: SynchronousQueue.h:128
virtual ~SynchronousQueue()
Definition: SynchronousQueue.h:96
virtual bool add(const E &value)=0
Returns true if this collection changed as a result of the call.
virtual bool offer(const E &value DECAF_UNUSED)
Inserts the specified element into this queue, if another thread is waiting to receive it...
Definition: SynchronousQueue.h:154
virtual E take()
Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it...
Definition: SynchronousQueue.h:169
virtual int drainTo(Collection< E > &c, int maxElements)
Removes at most the given number of available elements from this queue and adds them to the given col...
Definition: SynchronousQueue.h:294
Definition: IllegalArgumentException.h:31
Definition: IllegalStateException.h:32
virtual int drainTo(Collection< E > &c)
Removes all available elements from this queue and adds them to the given collection.
Definition: SynchronousQueue.h:275
#define DECAF_UNUSED
Definition: Config.h:160
Definition: NoSuchElementException.h:31
virtual bool containsAll(const Collection< E > &collection) const
Returns true if this collection contains all of the elements in the specified collection.The Collection to compare to this one.if the Collection contains pointers and the Collection does not allow for NULL elements (optional check).This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. If all elements are so contained true is returned, otherwise false.
Definition: SynchronousQueue.h:251
virtual decaf::util::Iterator< E > * iterator() const
Definition: SynchronousQueue.h:229
virtual decaf::util::Iterator< E > * iterator()
Definition: SynchronousQueue.h:225
virtual bool poll(E &result DECAF_UNUSED)
Retrieves and removes the head of this queue, if another thread is currently making an element availa...
Definition: SynchronousQueue.h:213
A blocking queue in which each insert operation must wait for a corresponding remove operation by ano...
Definition: SynchronousQueue.h:64
virtual E element() const
Gets but not removes the element in the head of the queue.Throws a NoSuchElementException if there is...
Definition: AbstractQueue.h:112
This class provides skeletal implementations of some Queue operations.
Definition: AbstractQueue.h:47
virtual int size() const
Returns the number of elements in this collection.
Definition: SynchronousQueue.h:237
virtual std::vector< E > toArray() const
Answers an STL vector containing copies of all elements contained in this Collection.
Definition: SynchronousQueue.h:271
virtual void clear()
Removes all of the elements from this collection (optional operation).The collection will be empty af...
Definition: SynchronousQueue.h:245
virtual bool contains(const E &value DECAF_UNUSED) const
Definition: SynchronousQueue.h:247
virtual bool equals(const Collection< E > &value) const
Answers true if this Collection and the one given are the same size and if each element contained in ...
Definition: SynchronousQueue.h:217
virtual bool removeAll(const Collection< E > &collection DECAF_UNUSED)
Definition: SynchronousQueue.h:259