Use context dispatcher everywhere

This commit is contained in:
Alexander Nozik 2021-11-29 14:24:39 +03:00
parent c2d2813622
commit 307d4cb18a
7 changed files with 11 additions and 9 deletions

View File

@ -120,7 +120,7 @@ abstract class AbstractPluginLoader : PluginLoader {
protected fun compare(p1: PluginFactory, p2: PluginFactory): Int { protected fun compare(p1: PluginFactory, p2: PluginFactory): Int {
return Integer.compare(p1.tag.getInt("priority", 0), p2.tag.getInt("priority", 0)) return p1.tag.getInt("priority", 0).compareTo(p2.tag.getInt("priority", 0))
} }
override fun listTags(): List<PluginTag> { override fun listTags(): List<PluginTag> {

View File

@ -19,7 +19,7 @@ application {
mainClass.set("inr.numass.viewer.Viewer") mainClass.set("inr.numass.viewer.Viewer")
} }
version = "0.6.0" version = "0.6.1"
description = "The viewer for numass data" description = "The viewer for numass data"

View File

@ -41,15 +41,15 @@ class DataController : Controller(), ContextAware {
val meta = point.meta val meta = point.meta
val channelSpectra: Deferred<Map<Int, Table>> = context.async(Dispatchers.IO) { val channelSpectra: Deferred<Map<Int, Table>> = context.async {
point.channels.mapValues { (_, value) -> analyzer.getAmplitudeSpectrum(value) } point.channels.mapValues { (_, value) -> analyzer.getAmplitudeSpectrum(value) }
} }
val spectrum: Deferred<Table> = context.async(Dispatchers.IO) { val spectrum: Deferred<Table> = context.async{
analyzer.getAmplitudeSpectrum(point) analyzer.getAmplitudeSpectrum(point)
} }
val timeSpectrum: Deferred<Table> = context.async(Dispatchers.IO) { val timeSpectrum: Deferred<Table> = context.async{
val cr = spectrum.await().sumOf { val cr = spectrum.await().sumOf {
it.getValue(NumassAnalyzer.COUNT_KEY).int it.getValue(NumassAnalyzer.COUNT_KEY).int
}.toDouble() / point.length.toMillis() * 1000 }.toDouble() / point.length.toMillis() * 1000
@ -117,7 +117,7 @@ class DataController : Controller(), ContextAware {
} }
} }
val watcher = watchPath.fileSystem.newWatchService() val watcher = watchPath.fileSystem.newWatchService()
watchJob = app.context.launch(Dispatchers.IO) { watchJob = app.context.launch {
watcher.use { watcher -> watcher.use { watcher ->
val key: WatchKey = watchPath.register(watcher, val key: WatchKey = watchPath.register(watcher,
StandardWatchEventKinds.ENTRY_CREATE) StandardWatchEventKinds.ENTRY_CREATE)

View File

@ -55,7 +55,7 @@ class HVView : View(title = "High voltage time plot", icon = ImageView(dfIcon))
} }
if (change.wasAdded()) { if (change.wasAdded()) {
runLater { container.progress = -1.0 } runLater { container.progress = -1.0 }
runGoal(app.context,"hvData[${change.key}]", Dispatchers.IO) { runGoal(app.context,"hvData[${change.key}]") {
change.valueAdded.getHvData() change.valueAdded.getHvData()
} ui { table -> } ui { table ->
if (table != null) { if (table != null) {

View File

@ -61,7 +61,7 @@ class MainView : View(title = "Numass viewer", icon = dfIconView) {
} }
if (Files.exists(path.resolve(NumassDataLoader.META_FRAGMENT_NAME))) { if (Files.exists(path.resolve(NumassDataLoader.META_FRAGMENT_NAME))) {
//build set view //build set view
runGoal(app.context, "viewer.load.set[$path]", Dispatchers.IO) { runGoal(app.context, "viewer.load.set[$path]") {
title = "Load set ($path)" title = "Load set ($path)"
message = "Building numass set..." message = "Building numass set..."
NumassDataLoader(app.context, null, path.fileName.toString(), path) NumassDataLoader(app.context, null, path.fileName.toString(), path)

View File

@ -43,7 +43,7 @@ class SlowControlView : View(title = "Numass slow control view", icon = ImageVie
plot.remove(change.key) plot.remove(change.key)
} }
if (change.wasAdded()) { if (change.wasAdded()) {
runGoal(app.context,"loadTable[${change.key}]", Dispatchers.IO) { runGoal(app.context,"loadTable[${change.key}]") {
val plotData = change.valueAdded.asTable().await() val plotData = change.valueAdded.asTable().await()
val names = plotData.format.namesAsArray().filter { it != "timestamp" } val names = plotData.format.namesAsArray().filter { it != "timestamp" }

View File

@ -8,6 +8,7 @@ import hep.dataforge.fx.dfIcon
import javafx.stage.Stage import javafx.stage.Stage
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import tornadofx.* import tornadofx.*
import kotlin.system.exitProcess
/** /**
* Created by darksnake on 14-Apr-17. * Created by darksnake on 14-Apr-17.
@ -28,6 +29,7 @@ class Viewer : App(MainView::class) {
context.close() context.close()
Global.terminate(); Global.terminate();
super.stop() super.stop()
exitProcess(0)
} }
} }