Package com.db4o.foundation
Class PausableBlockingQueue<T>
- java.lang.Object
-
- com.db4o.foundation.BlockingQueue<T>
-
- com.db4o.foundation.PausableBlockingQueue<T>
-
- All Implemented Interfaces:
BlockingQueue4<T>
,PausableBlockingQueue4<T>
,Queue4<T>
- Direct Known Subclasses:
TimeoutBlockingQueue
public class PausableBlockingQueue<T> extends BlockingQueue<T> implements PausableBlockingQueue4<T>
-
-
Field Summary
-
Fields inherited from class com.db4o.foundation.BlockingQueue
_lock, _queue, _stopped
-
-
Constructor Summary
Constructors Constructor Description PausableBlockingQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isPaused()
boolean
pause()
Pauses the queue, making calls toQueue4.next()
block untilPausableBlockingQueue4.resume()
is called.boolean
resume()
Resumes the queue, releasing blocked calls toQueue4.next()
that can reach a next queue item..T
tryNext()
Returns the next element in queue if there is one available, returns null otherwise.protected boolean
unsafeWaitForNext(long timeout)
-
Methods inherited from class com.db4o.foundation.BlockingQueue
add, drainTo, hasNext, iterator, next, next, nextMatching, stop, unsafeWaitForNext, waitForNext, waitForNext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.db4o.foundation.BlockingQueue4
drainTo, next, stop
-
-
-
-
Method Detail
-
pause
public boolean pause()
Description copied from interface:PausableBlockingQueue4
Pauses the queue, making calls to
Queue4.next()
block untilPausableBlockingQueue4.resume()
is called.- Specified by:
pause
in interfacePausableBlockingQueue4<T>
- Returns:
- whether or not this call changed the state of the queue.
-
resume
public boolean resume()
Description copied from interface:PausableBlockingQueue4
Resumes the queue, releasing blocked calls to
Queue4.next()
that can reach a next queue item..- Specified by:
resume
in interfacePausableBlockingQueue4<T>
- Returns:
- whether or not this call changed the state of the queue.
-
isPaused
public boolean isPaused()
- Specified by:
isPaused
in interfacePausableBlockingQueue4<T>
-
unsafeWaitForNext
protected boolean unsafeWaitForNext(long timeout) throws BlockingQueueStoppedException
- Overrides:
unsafeWaitForNext
in classBlockingQueue<T>
- Throws:
BlockingQueueStoppedException
-
tryNext
public T tryNext()
Description copied from interface:PausableBlockingQueue4
Returns the next element in queue if there is one available, returns null otherwise.
This method will not never block, regardless of the queue being paused or no elements are available.
- Specified by:
tryNext
in interfacePausableBlockingQueue4<T>
- Returns:
- next element, if available and queue not paused.
-
-