Package ai.preferred.venom.job
Class AbstractQueueScheduler
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<Job>
-
- ai.preferred.venom.job.AbstractQueueScheduler
-
- All Implemented Interfaces:
QueueScheduler
,java.lang.Iterable<Job>
,java.util.Collection<Job>
,java.util.concurrent.BlockingQueue<Job>
,java.util.Queue<Job>
- Direct Known Subclasses:
AbstractPriorityQueueScheduler
,FIFOQueueScheduler
public abstract class AbstractQueueScheduler extends java.util.AbstractQueue<Job> implements QueueScheduler
- Author:
- Ween Jiann Lee, Maksim Tkachenko
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractQueueScheduler(java.util.concurrent.BlockingQueue<Job> queue)
Constructs an instance of AbstractQueueScheduler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
drainTo(java.util.Collection<? super Job> c)
int
drainTo(java.util.Collection<? super Job> c, int maxElements)
protected java.util.concurrent.BlockingQueue<Job>
getQueue()
Get the BlockingQueue backing this scheduler.Scheduler
getScheduler()
Get the scheduler to add jobs.java.util.Iterator<Job>
iterator()
Job
peek()
int
remainingCapacity()
int
size()
Job
take()
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.BlockingQueue
add, contains, offer, offer, poll, put, remove
-
-
-
-
Constructor Detail
-
AbstractQueueScheduler
protected AbstractQueueScheduler(java.util.concurrent.BlockingQueue<Job> queue)
Constructs an instance of AbstractQueueScheduler.- Parameters:
queue
- an instance of BlockingQueue
-
-
Method Detail
-
getScheduler
public final Scheduler getScheduler()
Description copied from interface:QueueScheduler
Get the scheduler to add jobs.- Specified by:
getScheduler
in interfaceQueueScheduler
- Returns:
- an instance of Scheduler
-
iterator
@Nonnull public final java.util.Iterator<Job> iterator()
-
size
public final int size()
-
take
@Nonnull public final Job take() throws java.lang.InterruptedException
- Specified by:
take
in interfacejava.util.concurrent.BlockingQueue<Job>
- Throws:
java.lang.InterruptedException
-
remainingCapacity
public final int remainingCapacity()
- Specified by:
remainingCapacity
in interfacejava.util.concurrent.BlockingQueue<Job>
-
drainTo
public final int drainTo(@Nonnull java.util.Collection<? super Job> c)
- Specified by:
drainTo
in interfacejava.util.concurrent.BlockingQueue<Job>
-
drainTo
public final int drainTo(@Nonnull java.util.Collection<? super Job> c, int maxElements)
- Specified by:
drainTo
in interfacejava.util.concurrent.BlockingQueue<Job>
-
getQueue
protected final java.util.concurrent.BlockingQueue<Job> getQueue()
Get the BlockingQueue backing this scheduler.- Returns:
- an instance of BlockingQueue
-
-