mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
queue first when urgent
This commit is contained in:
@@ -75,7 +75,19 @@ public class FeedRefreshUpdater {
|
|||||||
locks = Striped.lazyWeakLock(threads * 100000);
|
locks = Striped.lazyWeakLock(threads * 100000);
|
||||||
pool = new ThreadPoolExecutor(threads, threads, 0,
|
pool = new ThreadPoolExecutor(threads, threads, 0,
|
||||||
TimeUnit.MILLISECONDS,
|
TimeUnit.MILLISECONDS,
|
||||||
queue = new LinkedBlockingDeque<Runnable>(500 * threads));
|
queue = new LinkedBlockingDeque<Runnable>(500 * threads) {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean offer(Runnable r) {
|
||||||
|
Task task = (Task) r;
|
||||||
|
if (task.getFeed().isUrgent()) {
|
||||||
|
return offerFirst(r);
|
||||||
|
} else {
|
||||||
|
return offerLast(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
pool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
|
pool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
|
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user