mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
inlined set/remove input for locks
aux method in fthread
This commit is contained in:
@@ -141,6 +141,10 @@ public class FThreads {
|
|||||||
return isEDT() ? "EDT" : Thread.currentThread().getName();
|
return isEDT() ? "EDT" : Thread.currentThread().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String prependThreadId(String message) {
|
||||||
|
return debugGetCurrThreadId() + " > " + message;
|
||||||
|
}
|
||||||
|
|
||||||
public static void dumpStackTrace(PrintStream stream) {
|
public static void dumpStackTrace(PrintStream stream) {
|
||||||
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
||||||
stream.printf("%s > %s called from %s%n", debugGetCurrThreadId(), trace[2].getClassName()+"."+trace[2].getMethodName(), trace[3].toString());
|
stream.printf("%s > %s called from %s%n", debugGetCurrThreadId(), trace[2].getClassName()+"."+trace[2].getMethodName(), trace[3].toString());
|
||||||
|
|||||||
@@ -175,13 +175,18 @@ public class InputQueue extends MyObservable implements java.io.Serializable {
|
|||||||
|
|
||||||
|
|
||||||
public void lock() {
|
public void lock() {
|
||||||
setInput(inputLock);
|
this.inputStack.push(inputLock);
|
||||||
|
this.updateObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unlock() {
|
public void unlock() {
|
||||||
|
FThreads.assertExecutedByEdt(false);
|
||||||
|
|
||||||
if ( inputStack.isEmpty() || inputStack.peek() != inputLock )
|
if ( inputStack.isEmpty() || inputStack.peek() != inputLock )
|
||||||
throw new RuntimeException("Trying to unlock input which is not locked (threading issue)! Input stack = " + inputStack);
|
throw new RuntimeException("Trying to unlock input which is not locked (threading issue)! Input stack = " + inputStack);
|
||||||
removeInput(inputLock);
|
|
||||||
|
inputStack.pop();
|
||||||
|
this.updateObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
// only for debug purposes
|
// only for debug purposes
|
||||||
|
|||||||
Reference in New Issue
Block a user