Fix flushing on main thread
This commit is contained in:
parent
6d52e47d3f
commit
64c00e4c3b
@ -134,8 +134,8 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
|
||||
@Override
|
||||
public boolean flush() {
|
||||
synchronized (this) {
|
||||
super.flush();
|
||||
synchronized (this) {
|
||||
boolean flushed = osBD != null || osNBTF != null || osNBTT != null && osENTCF != null || osENTCT != null;
|
||||
try {
|
||||
if (osBD != null) {
|
||||
|
@ -33,6 +33,8 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
|
||||
private final World world;
|
||||
|
||||
private final boolean mainThread;
|
||||
|
||||
public static FaweChangeSet getDefaultChangeSet(World world, UUID uuid) {
|
||||
if (Settings.HISTORY.USE_DISK) {
|
||||
return new DiskStorageHistory(world, uuid);
|
||||
@ -43,6 +45,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
|
||||
public FaweChangeSet(World world) {
|
||||
this.world = world;
|
||||
this.mainThread = Fawe.get().isMainThread();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
@ -174,7 +177,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
@Override
|
||||
public void run(final FaweChunk previous, final FaweChunk next) {
|
||||
waiting.incrementAndGet();
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@ -271,7 +274,12 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
if (mainThread) {
|
||||
new Thread(run).start();
|
||||
} else {
|
||||
TaskManager.IMP.async(run);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
|
||||
@Override
|
||||
public boolean flush() {
|
||||
synchronized (this) {
|
||||
super.flush();
|
||||
synchronized (this) {
|
||||
try {
|
||||
if (idsStream != null) {
|
||||
idsStreamZip.close();
|
||||
|
@ -478,10 +478,11 @@ public class LocalSession {
|
||||
} else {
|
||||
history.add(0, changeSet);
|
||||
}
|
||||
while ((history.size() > MAX_HISTORY_SIZE || (historySize >> 20) > limitMb) && history.size() > 1) {
|
||||
while (((!Settings.HISTORY.USE_DISK && history.size() > MAX_HISTORY_SIZE) || (historySize >> 20) > limitMb) && history.size() > 1) {
|
||||
FaweChangeSet item = (FaweChangeSet) history.remove(0);
|
||||
item.delete();
|
||||
historySize -= MainUtil.getSize(item);
|
||||
long size = MainUtil.getSize(item);
|
||||
historySize -= size;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user