diff --git a/core/src/main/kotlin/org/pastalab/fray/core/RunContext.kt b/core/src/main/kotlin/org/pastalab/fray/core/RunContext.kt index e371612..ebaa347 100644 --- a/core/src/main/kotlin/org/pastalab/fray/core/RunContext.kt +++ b/core/src/main/kotlin/org/pastalab/fray/core/RunContext.kt @@ -791,8 +791,14 @@ class RunContext(val config: Configuration) { fun latchAwait(latch: CountDownLatch, timed: Boolean) { val t = Thread.currentThread().id + val objId = System.identityHashCode(latch) val context = registeredThreads[t]!! val latchContext = latchManager.getContext(latch) + + context.pendingOperation = ObjectWaitOperation(objId) + context.state = ThreadState.Enabled + scheduleNextOperation(true) + if (latchContext.await(true, context)) { context.pendingOperation = CountDownLatchAwaitBlocking(timed, latchContext) context.state = ThreadState.Paused diff --git a/core/src/main/kotlin/org/pastalab/fray/core/scheduler/FrayIdeaPluginScheduler.kt b/core/src/main/kotlin/org/pastalab/fray/core/scheduler/FrayIdeaPluginScheduler.kt index 5c594e9..0e693e7 100644 --- a/core/src/main/kotlin/org/pastalab/fray/core/scheduler/FrayIdeaPluginScheduler.kt +++ b/core/src/main/kotlin/org/pastalab/fray/core/scheduler/FrayIdeaPluginScheduler.kt @@ -14,6 +14,9 @@ class FrayIdeaPluginScheduler : Scheduler { threads: List, allThreads: List ): ThreadContext { + if (threads.size == 1) { + return threads.first() + } val index = remoteScheduler.scheduleNextOperation(allThreads.map { it.toStackInfo() }) return allThreads[index] } diff --git a/plugins/idea/src/main/kotlin/org/pastalab/fray/idea/debugger/FrayDebuggerManager.kt b/plugins/idea/src/main/kotlin/org/pastalab/fray/idea/debugger/FrayDebuggerManager.kt index 317c821..cb89a9d 100644 --- a/plugins/idea/src/main/kotlin/org/pastalab/fray/idea/debugger/FrayDebuggerManager.kt +++ b/plugins/idea/src/main/kotlin/org/pastalab/fray/idea/debugger/FrayDebuggerManager.kt @@ -38,6 +38,7 @@ class FrayDebuggerManager(val debugSession: XDebugSession) : } fun stop() { + schedulerPanel.stop() registry.unbind("RemoteScheduler") UnicastRemoteObject.unexportObject(scheduler, true) } diff --git a/plugins/idea/src/main/kotlin/org/pastalab/fray/idea/ui/SchedulerPanel.kt b/plugins/idea/src/main/kotlin/org/pastalab/fray/idea/ui/SchedulerPanel.kt index 3b1032a..3431bfe 100644 --- a/plugins/idea/src/main/kotlin/org/pastalab/fray/idea/ui/SchedulerPanel.kt +++ b/plugins/idea/src/main/kotlin/org/pastalab/fray/idea/ui/SchedulerPanel.kt @@ -44,7 +44,6 @@ class SchedulerPanel(val project: Project) : JPanel() { init { layout = BorderLayout() - comboBox = ComboBox(comboBoxModel) comboBox.renderer = object : DefaultListCellRenderer() { @@ -99,6 +98,10 @@ class SchedulerPanel(val project: Project) : JPanel() { } } + fun stop() { + currentRangeHighlighters.forEach { it.first.removeHighlighter(it.second) } + } + fun comboBoxSelected(threadInfo: ThreadInfo) { myFrameListModel.clear() ApplicationManager.getApplication().invokeAndWait { @@ -159,12 +162,8 @@ class SchedulerPanel(val project: Project) : JPanel() { break } } - try { - enabledThreads.first { it.index == selected?.index }.let { comboBoxModel.selectedItem = it } - } catch (e: NoSuchElementException) { - comboBoxModel.selectedItem = enabledThreads.first() - } - + comboBoxModel.selectedItem = + enabledThreads.find { it.index == selected?.index } ?: enabledThreads.first() callback = onThreadSelected }