Forgot to flush changeset for VS

This commit is contained in:
Jesse Boyd 2016-09-04 18:14:04 +10:00
parent dba271ba78
commit 9f93f56c05
5 changed files with 29 additions and 18 deletions

View File

@ -333,7 +333,7 @@ public abstract class FaweQueue {
* Lock the thread until the queue is empty
*/
public void flush() {
flush(Integer.MAX_VALUE);
flush(10000);
}
/**
@ -344,21 +344,22 @@ public abstract class FaweQueue {
if (Fawe.get().isMainThread()) {
SetQueue.IMP.flush(this);
} else {
enqueue();
final AtomicBoolean running = new AtomicBoolean(true);
addNotifyTask(new Runnable() {
@Override
public void run() {
TaskManager.IMP.notify(running);
}
});
TaskManager.IMP.wait(running, time);
if (enqueue()) {
final AtomicBoolean running = new AtomicBoolean(true);
addNotifyTask(new Runnable() {
@Override
public void run() {
TaskManager.IMP.notify(running);
}
});
TaskManager.IMP.wait(running, time);
}
}
}
}
public void enqueue() {
SetQueue.IMP.enqueue(this);
public boolean enqueue() {
return SetQueue.IMP.enqueue(this);
}
public void dequeue() {

View File

@ -235,7 +235,7 @@ public class DelegateFaweQueue extends FaweQueue {
}
@Override
public void enqueue() {
parent.enqueue();
public boolean enqueue() {
return parent.enqueue();
}
}

View File

@ -140,12 +140,16 @@ public class SetQueue {
return false;
}
public void enqueue(FaweQueue queue) {
public boolean enqueue(FaweQueue queue) {
inactiveQueues.remove(queue);
if (queue.size() > 0 && !activeQueues.contains(queue)) {
queue.optimize();
activeQueues.add(queue);
if (queue.size() > 0) {
if (!activeQueues.contains(queue)) {
queue.optimize();
activeQueues.add(queue);
}
return true;
}
return false;
}
public void dequeue(FaweQueue queue) {

View File

@ -270,9 +270,13 @@ public abstract class TaskManager {
public void wait(AtomicBoolean running, int timout) {
try {
long start = System.currentTimeMillis();
synchronized (running) {
while (running.get()) {
running.wait(timout);
if (running.get() && System.currentTimeMillis() - start > Settings.QUEUE.DISCARD_AFTER_MS) {
MainUtil.stacktrace();
}
}
}
} catch (InterruptedException e) {

View File

@ -465,6 +465,8 @@ public class LocalSession {
}
}
FaweChangeSet changeSet = (FaweChangeSet) editSession.getChangeSet();
// Just in case
changeSet.flush();
historySize += MainUtil.getSize(changeSet);
if (append) {
history.add(changeSet);