Skip to content

Commit

Permalink
#23 replace LinkedList by ConcurrentLinkedQueue for idChunkQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
mincong-h committed Jun 6, 2016
1 parent e4c9f04 commit 4474125
Showing 1 changed file with 7 additions and 7 deletions.
@@ -1,8 +1,7 @@
package io.github.mincongh.batch;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

import javax.inject.Named;
import javax.inject.Singleton;
Expand All @@ -13,22 +12,23 @@
@Singleton
public class IndexingContext {

private Queue<Serializable[]> idChunkQueue;
private ConcurrentLinkedQueue<Serializable[]> idChunkQueue;

private IndexShardingStrategy indexShardingStrategy;

public IndexingContext() {
this.idChunkQueue = new LinkedList<Serializable[]>();
this.idChunkQueue = new ConcurrentLinkedQueue<>();
}

public synchronized void add(Serializable[] idArray) {
public void add(Serializable[] idArray) {
idChunkQueue.add(idArray);
}

public synchronized Serializable[] poll() {
public Serializable[] poll() {
return idChunkQueue.poll();
}

public synchronized int size() {
public int size() {
return idChunkQueue.size();
}

Expand Down

0 comments on commit 4474125

Please sign in to comment.