mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +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();
|
||||
}
|
||||
|
||||
public static String prependThreadId(String message) {
|
||||
return debugGetCurrThreadId() + " > " + message;
|
||||
}
|
||||
|
||||
public static void dumpStackTrace(PrintStream stream) {
|
||||
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
||||
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() {
|
||||
setInput(inputLock);
|
||||
this.inputStack.push(inputLock);
|
||||
this.updateObservers();
|
||||
}
|
||||
|
||||
public void unlock() {
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
|
||||
if ( inputStack.isEmpty() || inputStack.peek() != inputLock )
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user