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> {
74 "Cannot traverse a Synchronous Queue." );
77 virtual bool hasNext()
const {
81 virtual void remove() {
85 "No Elements to remove from a Synchronous Queue." );
110 virtual void put(
const E& value ) {
156 virtual bool offer(
const E& value ) {
195 virtual bool poll( E& result,
long long timeout,
const TimeUnit& unit ) {
215 virtual bool poll( E& result ) {
220 if( (
void*)&value ==
this ) {
228 return new EmptyIterator();
232 return new EmptyIterator();
273 virtual std::vector<E>
toArray()
const {
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 ) ) {
virtual std::vector< E > toArray() const
Answers an STL vector containing copies of all elements contained in this Collection.
Definition: SynchronousQueue.h:273
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:219
virtual bool peek(E &result DECAF_UNUSED) const
Definition: SynchronousQueue.h:269
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
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:265
SynchronousQueue()
Definition: SynchronousQueue.h:96
virtual void put(const E &value)
Adds the specified element to this queue, waiting if necessary for another thread to receive it...
Definition: SynchronousQueue.h:110
virtual bool isEmpty() const =0
virtual bool contains(const E &value DECAF_UNUSED) const
Definition: SynchronousQueue.h:249
Defines an object that can be used to iterate over the elements of a collection.
Definition: Iterator.h:34
virtual int size() const
Returns the number of elements in this collection.
Definition: SynchronousQueue.h:239
virtual bool isEmpty() const
Returns true if this collection contains no elements.
Definition: SynchronousQueue.h:235
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:243
A TimeUnit represents time durations at a given unit of granularity and provides utility methods to c...
Definition: TimeUnit.h:62
virtual ~SynchronousQueue()
Definition: SynchronousQueue.h:98
virtual bool add(const E &value)=0
Returns true if this collection changed as a result of the call.
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:253
virtual bool poll(E &result, long long timeout, const TimeUnit &unit)
Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time...
Definition: SynchronousQueue.h:195
virtual bool poll(E &result)
Retrieves and removes the head of this queue, if another thread is currently making an element availa...
Definition: SynchronousQueue.h:215
virtual E take()
Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it...
Definition: SynchronousQueue.h:171
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 bool offer(const E &e, long long timeout, const TimeUnit &unit)
Inserts the specified element into this queue, waiting if necessary up to the specified wait time for...
Definition: SynchronousQueue.h:130
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 decaf::util::Iterator< E > * iterator()
Definition: SynchronousQueue.h:227
A blocking queue in which each insert operation must wait for a corresponding remove operation by ano...
Definition: SynchronousQueue.h:64
virtual bool offer(const E &value)
Inserts the specified element into this queue, if another thread is waiting to receive it...
Definition: SynchronousQueue.h:156
virtual void clear()
Removes all of the elements from this collection (optional operation).The collection will be empty af...
Definition: SynchronousQueue.h:247
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25
virtual decaf::util::Iterator< E > * iterator() const
Definition: SynchronousQueue.h:231
virtual bool removeAll(const Collection< E > &collection DECAF_UNUSED)
Definition: SynchronousQueue.h:261