[ci skip] Avoid call currentThread() twice on ensures pakcet safety

This commit is contained in:
Sotr
2019-03-18 19:55:38 +08:00
parent 7a3490a487
commit ccbe5f8f93
4 changed files with 31 additions and 2 deletions

View File

@@ -1681,7 +1681,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
if (!this.isMainThread()) { // CraftBukkit && !this.isStopped()) {
ListenableFutureTask<V> listenablefuturetask = ListenableFutureTask.create(callable);
this.f.add(listenablefuturetask);
this.f.offer(listenablefuturetask); // Akarin - add -> offer
return listenablefuturetask;
} else {
try {
@@ -1691,6 +1691,12 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
}
}
}
// Akarin start
@Override
public void ensuresMainThread(Runnable runnable) {
this.f.offer(ListenableFutureTask.create(runnable, null));
}
// Akarin end
public ListenableFuture<Object> postToMainThread(Runnable runnable) {
Validate.notNull(runnable);