18#ifndef _DECAF_UTIL_CONCURRENT_SYNCHRONOUSQUEUE_H_
19#define _DECAF_UTIL_CONCURRENT_SYNCHRONOUSQUEUE_H_
63 template<
typename E >
67 class EmptyIterator :
public Iterator<E> {
73 "Cannot traverse a Synchronous Queue.");
76 virtual bool hasNext()
const {
83 "No Elements to remove from a Synchronous Queue.");
90 SynchronousQueue& operator=(
const SynchronousQueue&);
108 virtual void put(
const E& value DECAF_UNUSED) {
128 virtual bool offer(
const E& e DECAF_UNUSED,
long long timeout DECAF_UNUSED,
const TimeUnit& unit DECAF_UNUSED) {
154 virtual bool offer(
const E& value DECAF_UNUSED) {
193 virtual bool poll(E& result DECAF_UNUSED,
long long timeout DECAF_UNUSED,
const TimeUnit& unit DECAF_UNUSED) {
213 virtual bool poll(E& result DECAF_UNUSED) {
218 if ((
void*) &value ==
this) {
226 return new EmptyIterator();
230 return new EmptyIterator();
247 virtual bool contains(
const E& value DECAF_UNUSED)
const {
255 virtual bool remove(
const E& value DECAF_UNUSED) {
267 virtual bool peek(E& result DECAF_UNUSED)
const {
272 return std::vector<E>();
277 if ((
void*) &c ==
this) {
280 "Cannot drain a Collection to Itself.");
296 if ((
void*) &c ==
this) {
299 "Cannot drain a Collection to Itself.");
305 while (count < maxElements && (
poll(
element) !=
false)) {
Definition IllegalArgumentException.h:31
Definition IllegalStateException.h:32
This class provides skeletal implementations of some Queue operations.
Definition AbstractQueue.h:48
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
virtual E remove()
Gets and removes the element in the head of the queue.Throws a NoSuchElementException if there is no ...
Definition AbstractQueue.h:95
The root interface in the collection hierarchy.
Definition Collection.h:69
virtual bool add(const E &value)=0
Returns true if this collection changed as a result of the call.
virtual bool isEmpty() const =0
Defines an object that can be used to iterate over the elements of a collection.
Definition Iterator.h:34
Definition NoSuchElementException.h:31
A decaf::util::Queue that additionally supports operations that wait for the queue to become non-empt...
Definition BlockingQueue.h:164
virtual bool equals(const Collection< E > &value) const
Compares the passed collection to this one, if they contain the same elements, i.e.
Definition SynchronousQueue.h:217
virtual void clear()
Removes all of the elements from this collection (optional operation).This collection will be empty a...
Definition SynchronousQueue.h:245
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
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
virtual ~SynchronousQueue()
Definition SynchronousQueue.h:96
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 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
virtual bool remove(const E &value DECAF_UNUSED)
Definition SynchronousQueue.h:255
virtual bool removeAll(const Collection< E > &collection DECAF_UNUSED)
Definition SynchronousQueue.h:259
virtual decaf::util::Iterator< E > * iterator() const
Definition SynchronousQueue.h:229
virtual int size() const
Returns the number of elements in this collection.
Definition SynchronousQueue.h:237
virtual bool retainAll(const Collection< E > &collection DECAF_UNUSED)
Definition SynchronousQueue.h:263
virtual int drainTo(Collection< E > &c)
Removes all available elements from this queue and adds them to the given collection.
Definition SynchronousQueue.h:275
virtual std::vector< E > toArray() const
Returns an array containing all of the elements in this collection.
Definition SynchronousQueue.h:271
virtual bool containsAll(const Collection< E > &collection) const
Returns true if this collection contains all of the elements in the specified collection.
Definition SynchronousQueue.h:251
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 bool isEmpty() const
Definition SynchronousQueue.h:233
virtual bool contains(const E &value DECAF_UNUSED) const
Definition SynchronousQueue.h:247
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
SynchronousQueue()
Definition SynchronousQueue.h:94
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 decaf::util::Iterator< E > * iterator()
Definition SynchronousQueue.h:225
virtual bool peek(E &result DECAF_UNUSED) const
Definition SynchronousQueue.h:267
virtual E take()
Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it.
Definition SynchronousQueue.h:169
A TimeUnit represents time durations at a given unit of granularity and provides utility methods to c...
Definition TimeUnit.h:62
Definition AbstractExecutorService.h:28
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25