Package org.appng.api.search
Class BlockingQueueAccessor<E>
- java.lang.Object
-
- org.appng.api.search.BlockingQueueAccessor<E>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BlockingQueueAccessor()
Creates a newBlockingQueueAccessor
with a queue size of 100}.protected
BlockingQueueAccessor(int queueSize)
Creates a newBlockingQueueAccessor
with the given queue size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description E
get()
Retrieves and removes the head of the queue.
This is a blocking operation!E
get(long timeoutMillis)
Retrieves and removes the head of the queue, waiting up totimeoutMillis
milliseconds if necessary.protected BlockingQueue<E>
getBlockingQueue()
E
getWithTimeout(long timeoutMillis)
Retrieves and removes the head of the queue, waiting up totimeoutMillis
milliseconds if necessary.void
put(E element)
Puts the givenelement
into the queue.
This is a blocking operation!boolean
put(E element, long timeoutMillis)
Puts the givenelement
into the queue, waiting up totimeoutMillis
milliseconds if necessary.
This is a blocking operation!void
putWithTimeout(E element, long timeoutMillis)
Puts the givenelement
into the queue, waiting up totimeoutMillis
milliseconds if necessary.
-
-
-
Constructor Detail
-
BlockingQueueAccessor
protected BlockingQueueAccessor(int queueSize)
Creates a newBlockingQueueAccessor
with the given queue size.- Parameters:
queueSize
- the size of the internalBlockingQueue
-
BlockingQueueAccessor
protected BlockingQueueAccessor()
Creates a newBlockingQueueAccessor
with a queue size of 100}.
-
-
Method Detail
-
put
public void put(E element) throws InterruptedException
Puts the givenelement
into the queue.
This is a blocking operation!- Parameters:
element
- the element of type<E>
to put to the queue- Throws:
InterruptedException
- if interrupted while waiting
-
put
public boolean put(E element, long timeoutMillis) throws InterruptedException
Puts the givenelement
into the queue, waiting up totimeoutMillis
milliseconds if necessary.
This is a blocking operation!- Parameters:
element
- the element of type<E>
to put into the queuetimeoutMillis
- the time to wait in milliseconds- Returns:
true
if the element could be added before the timeout,false
otherwise- Throws:
InterruptedException
- if interrupted while waiting
-
putWithTimeout
public void putWithTimeout(E element, long timeoutMillis) throws InterruptedException, TimeoutException
Puts the givenelement
into the queue, waiting up totimeoutMillis
milliseconds if necessary. If no element could be added, aTimeoutException
is thrown.
This is a blocking operation!- Parameters:
element
- the element of type<E>
to put to the queuetimeoutMillis
- the time to wait in milliseconds- Throws:
InterruptedException
- if interrupted while waitingTimeoutException
- if a timeout occurred while waiting
-
get
public E get() throws InterruptedException
Retrieves and removes the head of the queue.
This is a blocking operation!- Returns:
- an element of type
<E>
- Throws:
InterruptedException
- if interrupted while waiting
-
get
public E get(long timeoutMillis) throws InterruptedException
Retrieves and removes the head of the queue, waiting up totimeoutMillis
milliseconds if necessary. If no element could be retrieved,null
is returned.
This is a blocking operation!- Parameters:
timeoutMillis
- the time to wait in milliseconds- Returns:
- an element of type
<E>
, ornull
if no element could be retrieved intimeoutMillis
milliseconds - Throws:
InterruptedException
- if interrupted while waiting
-
getWithTimeout
public E getWithTimeout(long timeoutMillis) throws InterruptedException, TimeoutException
Retrieves and removes the head of the queue, waiting up totimeoutMillis
milliseconds if necessary. If no element could be retrieved, aTimeoutException
is thrown.
This is a blocking operation!- Parameters:
timeoutMillis
- the time to wait in milliseconds- Returns:
- an element of type
<E>
- Throws:
InterruptedException
- if interrupted while waitingTimeoutException
- if a timeout occurred while waiting
-
getBlockingQueue
protected BlockingQueue<E> getBlockingQueue()
-
-