Massively improved thread safety

This commit is contained in:
Anuken
2018-10-20 11:25:58 -04:00
parent 22328772ca
commit b1cda57174
8 changed files with 69 additions and 31 deletions

View File

@@ -1,11 +1,27 @@
package io.anuke.kryonet;
import io.anuke.mindustry.core.ThreadHandler.ThreadProvider;
import io.anuke.ucore.util.Threads;
import io.anuke.ucore.util.Threads.ThreadInfoProvider;
import io.anuke.ucore.util.Log;
public class DefaultThreadImpl implements ThreadProvider {
public class DefaultThreadImpl implements ThreadProvider, ThreadInfoProvider{
private Thread thread;
public DefaultThreadImpl(){
Threads.setThreadInfoProvider(this);
}
@Override
public boolean isOnLogicThread(){
return thread == null || isOnThread();
}
@Override
public boolean isOnGraphicsThread(){
return thread == null || !isOnThread();
}
@Override
public boolean isOnThread() {
return Thread.currentThread() == thread;