org.jnetpcap.util
Class BlockingQueuePump<T>

java.lang.Object
  extended by org.jnetpcap.util.BlockingQueuePump<T>
Type Parameters:
T - the generic type
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Collection<T>, java.util.concurrent.BlockingQueue<T>, java.util.Queue<T>

public abstract class BlockingQueuePump<T>
extends java.lang.Object
implements java.util.concurrent.BlockingQueue<T>

The Class BlockingQueuePump.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Field Summary
 java.lang.Runnable dispatchQueue
          The dispatch queue.
 
Constructor Summary
BlockingQueuePump(java.lang.String name)
          Unlimited capacity queue.
BlockingQueuePump(java.lang.String name, int capacity)
          A limited in capacity queue.
 
Method Summary
 boolean add(T o)
          Adds the.
 boolean addAll(java.util.Collection<? extends T> c)
          Adds the all.
 void clear()
          Clear.
 boolean contains(java.lang.Object o)
          Contains.
 boolean containsAll(java.util.Collection<?> c)
          Contains all.
protected abstract  void dispatch(T data)
          Dispatch.
 int drainTo(java.util.Collection<? super T> c)
          Drain to.
 int drainTo(java.util.Collection<? super T> c, int maxElements)
          Drain to.
 T element()
          Element.
 boolean equals(java.lang.Object o)
          Equals.
 int hashCode()
          Hash code.
 boolean isAlive()
          Checks if is alive.
 boolean isEmpty()
          Checks if is empty.
 java.util.Iterator<T> iterator()
          Iterator.
 boolean offer(T o)
          Offer.
 boolean offer(T o, long timeout, java.util.concurrent.TimeUnit unit)
          Offer.
 T peek()
          Peek.
 T poll()
          Poll.
 T poll(long timeout, java.util.concurrent.TimeUnit unit)
          Poll.
 void put(T o)
          Put.
 int remainingCapacity()
          Remaining capacity.
 T remove()
          Removes the.
 boolean remove(java.lang.Object o)
          Removes the.
 boolean removeAll(java.util.Collection<?> c)
          Removes the all.
 boolean retainAll(java.util.Collection<?> c)
          Retain all.
 int size()
          Size.
 void start()
          Start.
 void stop()
          Stop.
 T take()
          Take.
 java.lang.Object[] toArray()
          To array.
<Q> Q[]
toArray(Q[] a)
          To array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dispatchQueue

public java.lang.Runnable dispatchQueue
The dispatch queue.

Constructor Detail

BlockingQueuePump

public BlockingQueuePump(java.lang.String name)
Unlimited capacity queue.

Parameters:
name - name to use for the worker thread

BlockingQueuePump

public BlockingQueuePump(java.lang.String name,
                         int capacity)
A limited in capacity queue.

Parameters:
name - name to use for the workder thread
capacity - maximum capacity of the queue
Method Detail

add

public boolean add(T o)
Adds the.

Specified by:
add in interface java.util.Collection<T>
Specified by:
add in interface java.util.concurrent.BlockingQueue<T>
Specified by:
add in interface java.util.Queue<T>
Parameters:
o - the o
Returns:
true, if successful
See Also:
BlockingQueue.add(java.lang.Object)

addAll

public boolean addAll(java.util.Collection<? extends T> c)
Adds the all.

Specified by:
addAll in interface java.util.Collection<T>
Parameters:
c - the c
Returns:
true, if successful
See Also:
Collection.addAll(java.util.Collection)

clear

public void clear()
Clear.

Specified by:
clear in interface java.util.Collection<T>
See Also:
Collection.clear()

contains

public boolean contains(java.lang.Object o)
Contains.

Specified by:
contains in interface java.util.Collection<T>
Specified by:
contains in interface java.util.concurrent.BlockingQueue<T>
Parameters:
o - the o
Returns:
true, if successful
See Also:
Collection.contains(java.lang.Object)

containsAll

public boolean containsAll(java.util.Collection<?> c)
Contains all.

Specified by:
containsAll in interface java.util.Collection<T>
Parameters:
c - the c
Returns:
true, if successful
See Also:
Collection.containsAll(java.util.Collection)

dispatch

protected abstract void dispatch(T data)
Dispatch.

Parameters:
data - the data

drainTo

public int drainTo(java.util.Collection<? super T> c)
Drain to.

Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<T>
Parameters:
c - the c
Returns:
the int
See Also:
BlockingQueue.drainTo(java.util.Collection)

drainTo

public int drainTo(java.util.Collection<? super T> c,
                   int maxElements)
Drain to.

Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<T>
Parameters:
c - the c
maxElements - the max elements
Returns:
the int
See Also:
BlockingQueue.drainTo(java.util.Collection, int)

element

public T element()
Element.

Specified by:
element in interface java.util.Queue<T>
Returns:
the t
See Also:
Queue.element()

equals

public boolean equals(java.lang.Object o)
Equals.

Specified by:
equals in interface java.util.Collection<T>
Overrides:
equals in class java.lang.Object
Parameters:
o - the o
Returns:
true, if successful
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Hash code.

Specified by:
hashCode in interface java.util.Collection<T>
Overrides:
hashCode in class java.lang.Object
Returns:
the int
See Also:
Object.hashCode()

isAlive

public boolean isAlive()
Checks if is alive.

Returns:
true, if is alive

isEmpty

public boolean isEmpty()
Checks if is empty.

Specified by:
isEmpty in interface java.util.Collection<T>
Returns:
true, if is empty
See Also:
Collection.isEmpty()

iterator

public java.util.Iterator<T> iterator()
Iterator.

Specified by:
iterator in interface java.lang.Iterable<T>
Specified by:
iterator in interface java.util.Collection<T>
Returns:
the iterator
See Also:
Collection.iterator()

offer

public boolean offer(T o)
Offer.

Specified by:
offer in interface java.util.concurrent.BlockingQueue<T>
Specified by:
offer in interface java.util.Queue<T>
Parameters:
o - the o
Returns:
true, if successful
See Also:
BlockingQueue.offer(java.lang.Object)

offer

public boolean offer(T o,
                     long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException
Offer.

Specified by:
offer in interface java.util.concurrent.BlockingQueue<T>
Parameters:
o - the o
timeout - the timeout
unit - the unit
Returns:
true, if successful
Throws:
java.lang.InterruptedException - the interrupted exception
See Also:
BlockingQueue.offer(java.lang.Object, long, java.util.concurrent.TimeUnit)

peek

public T peek()
Peek.

Specified by:
peek in interface java.util.Queue<T>
Returns:
the t
See Also:
Queue.peek()

poll

public T poll()
Poll.

Specified by:
poll in interface java.util.Queue<T>
Returns:
the t
See Also:
Queue.poll()

poll

public T poll(long timeout,
              java.util.concurrent.TimeUnit unit)
       throws java.lang.InterruptedException
Poll.

Specified by:
poll in interface java.util.concurrent.BlockingQueue<T>
Parameters:
timeout - the timeout
unit - the unit
Returns:
the t
Throws:
java.lang.InterruptedException - the interrupted exception
See Also:
BlockingQueue.poll(long, java.util.concurrent.TimeUnit)

put

public void put(T o)
         throws java.lang.InterruptedException
Put.

Specified by:
put in interface java.util.concurrent.BlockingQueue<T>
Parameters:
o - the o
Throws:
java.lang.InterruptedException - the interrupted exception
See Also:
BlockingQueue.put(java.lang.Object)

remainingCapacity

public int remainingCapacity()
Remaining capacity.

Specified by:
remainingCapacity in interface java.util.concurrent.BlockingQueue<T>
Returns:
the int
See Also:
BlockingQueue.remainingCapacity()

remove

public T remove()
Removes the.

Specified by:
remove in interface java.util.Queue<T>
Returns:
the t
See Also:
Queue.remove()

remove

public boolean remove(java.lang.Object o)
Removes the.

Specified by:
remove in interface java.util.Collection<T>
Specified by:
remove in interface java.util.concurrent.BlockingQueue<T>
Parameters:
o - the o
Returns:
true, if successful
See Also:
Collection.remove(java.lang.Object)

removeAll

public boolean removeAll(java.util.Collection<?> c)
Removes the all.

Specified by:
removeAll in interface java.util.Collection<T>
Parameters:
c - the c
Returns:
true, if successful
See Also:
Collection.removeAll(java.util.Collection)

retainAll

public boolean retainAll(java.util.Collection<?> c)
Retain all.

Specified by:
retainAll in interface java.util.Collection<T>
Parameters:
c - the c
Returns:
true, if successful
See Also:
Collection.retainAll(java.util.Collection)

size

public int size()
Size.

Specified by:
size in interface java.util.Collection<T>
Returns:
the int
See Also:
Collection.size()

start

public void start()
Start.


stop

public void stop()
Stop.


take

public T take()
       throws java.lang.InterruptedException
Take.

Specified by:
take in interface java.util.concurrent.BlockingQueue<T>
Returns:
the t
Throws:
java.lang.InterruptedException - the interrupted exception
See Also:
BlockingQueue.take()

toArray

public java.lang.Object[] toArray()
To array.

Specified by:
toArray in interface java.util.Collection<T>
Returns:
the object[]
See Also:
Collection.toArray()

toArray

public <Q> Q[] toArray(Q[] a)
To array.

Specified by:
toArray in interface java.util.Collection<T>
Type Parameters:
Q - the generic type
Parameters:
a - the a
Returns:
the q[]
See Also:
Collection.toArray(Object[])