Skip to content

Commit c5890b4

Browse files
committed
Use coroutines instead of Threads
1 parent 32973ca commit c5890b4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<!-- NB: Work around duplicate classes issue in Kotlin dependencies-->
8787
<allowedDuplicateClasses>org/jetbrains/kotlin/daemon/common/*,kotlinx/coroutines/**</allowedDuplicateClasses>
8888

89+
<kotlinx-coroutines-core.version>1.3.1</kotlinx-coroutines-core.version>
8990
<scripting-kotlin.version>0.1.1</scripting-kotlin.version>
9091
</properties>
9192

@@ -101,6 +102,11 @@
101102
<groupId>org.jetbrains.kotlin</groupId>
102103
<artifactId>kotlin-stdlib-jdk8</artifactId>
103104
</dependency>
105+
<dependency>
106+
<groupId>org.jetbrains.kotlinx</groupId>
107+
<artifactId>kotlinx-coroutines-core</artifactId>
108+
<version>${kotlinx-coroutines-core.version}</version>
109+
</dependency>
104110

105111
<!-- Test dependencies -->
106112
<dependency>

src/main/kotlin/org/scijava/scripting/fx/ScijavaReplFXTabs.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import javafx.scene.input.KeyCode
88
import javafx.scene.input.KeyCodeCombination
99
import javafx.scene.input.KeyCombination
1010
import javafx.scene.input.KeyEvent
11+
import kotlinx.coroutines.GlobalScope
12+
import kotlinx.coroutines.launch
1113
import org.scijava.Context
1214

1315
class ScijavaReplFXTabs(
@@ -59,8 +61,7 @@ class ScijavaReplFXTabs(
5961
when {
6062
evalKeys.any { c -> c.match(it) } -> {
6163
it.consume()
62-
// TODO use coroutines instead of thread
63-
Thread { repl.evalCurrentPrompt() }.start()
64+
GlobalScope.launch { repl.evalCurrentPrompt() }
6465
}
6566
cycleTabsForwardKombination.any { c -> c.match(it) } -> {
6667
it.consume()

0 commit comments

Comments
 (0)