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

View File

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

View File

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

View File

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

View File

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