inlined set/remove input for locks

aux method in fthread
This commit is contained in:
Maxmtg
2013-05-27 15:11:24 +00:00
parent 9766a369cb
commit 142b07ff5a
2 changed files with 11 additions and 2 deletions

View File

@@ -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());

View File

@@ -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