mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
scale based on number of background threads
This commit is contained in:
@@ -11,6 +11,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import com.commafeed.backend.dao.FeedDAO;
|
import com.commafeed.backend.dao.FeedDAO;
|
||||||
import com.commafeed.backend.model.Feed;
|
import com.commafeed.backend.model.Feed;
|
||||||
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -19,12 +20,17 @@ public class FeedRefreshTaskGiver {
|
|||||||
@Inject
|
@Inject
|
||||||
FeedDAO feedDAO;
|
FeedDAO feedDAO;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ApplicationSettingsService applicationSettingsService;
|
||||||
|
|
||||||
private Queue<Feed> queue = Lists.newLinkedList();
|
private Queue<Feed> queue = Lists.newLinkedList();
|
||||||
|
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
public Feed take() {
|
public Feed take() {
|
||||||
if (queue.peek() == null) {
|
if (queue.peek() == null) {
|
||||||
List<Feed> feeds = feedDAO.findNextUpdatable(30);
|
List<Feed> feeds = feedDAO
|
||||||
|
.findNextUpdatable(30 * applicationSettingsService.get()
|
||||||
|
.getBackgroundThreads());
|
||||||
for (Feed feed : feeds) {
|
for (Feed feed : feeds) {
|
||||||
queue.add(feed);
|
queue.add(feed);
|
||||||
feed.setLastUpdated(Calendar.getInstance().getTime());
|
feed.setLastUpdated(Calendar.getInstance().getTime());
|
||||||
|
|||||||
Reference in New Issue
Block a user