Commit eaae85d9 authored by Luna Riegel's avatar Luna Riegel
Browse files

Refactor: Delete useless class

parent 3ba87aec
package de.hft.stuttgart.citydoctor2.check;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.parser.ProgressListener;
import java.util.EmptyStackException;
import java.util.Stack;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
public class CheckerThreadsSynchronizer {
private AtomicInteger checkedCount = new AtomicInteger(0);
private final float featureCount;
private CityDoctorModel model;
private ProgressListener listener;
private ReentrantLock lock = new ReentrantLock();
private Stack<GmlId> ids;
public CheckerThreadsSynchronizer(CityDoctorModel model, ProgressListener listener) {
this.model = model;
this.listener = listener;
featureCount = model.getNumberOfFeatures();
ids = new Stack<>();
ids.addAll(model.getFeatureIds());
}
public CityObject getNext() {
// lock.lock();
// try {
if (!ids.isEmpty()){
return model.getCache().get(ids.pop());
}
return null;
// } finally {
// lock.unlock();
// }
};
public void updateFeature(CityObject feature) {
model.getCache().put(feature);
}
public boolean hasNext(){
// lock.lock();
try {
ids.peek();
return true;
} catch (EmptyStackException e) {
return false;
} finally {
// lock.unlock();
}
}
public void updateCheckedCount(){
checkedCount.getAndIncrement();
if (listener!=null){
listener.updateProgress(checkedCount.get() / featureCount);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment