public class LazyScheduler extends AbstractQueueScheduler
Jobs in queue will be processed first in order of higher priority, followed by requests in the iterator.
Constructor and Description |
---|
LazyScheduler(Iterator<Request> requests)
Constructs an instance of lazy scheduler without a default handler.
|
LazyScheduler(Iterator<Request> requests,
Handler handler)
Constructs an instance of lazy scheduler with a default handler.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Request r,
Handler h,
Priority p,
Priority pf)
Adds a request to the queue.
|
boolean |
isEmpty() |
boolean |
offer(Job job,
long timeout,
TimeUnit unit) |
Job |
poll() |
Job |
poll(long time,
TimeUnit unit) |
void |
put(Job job) |
add, add, add, add, add, drainTo, drainTo, iterator, offer, peek, remainingCapacity, size, take
contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, contains, remove
addAll, clear, containsAll, equals, hashCode, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
public LazyScheduler(Iterator<Request> requests, Handler handler)
requests
- An iterator to obtain requestshandler
- The default handler to usepublic final void add(Request r, Handler h, Priority p, Priority pf)
Scheduler
This request would be parsed by the handler specified, and its priority can be downgraded to a minimum priority specified.
r
- request to fetch when dequeuedh
- handler to be used to parse the requestp
- initial priority of the requestpf
- the minimum (floor) priority of this requestpublic final Job poll()
poll
in interface Queue<Job>
poll
in class AbstractQueueScheduler
public final Job poll(long time, @Nonnull TimeUnit unit) throws InterruptedException
poll
in interface BlockingQueue<Job>
poll
in class AbstractQueueScheduler
InterruptedException
public final boolean isEmpty()
isEmpty
in interface Collection<Job>
isEmpty
in class AbstractCollection<Job>
Copyright © 2019. All rights reserved.