Implement graceful shutdown
This commit is contained in:
parent
13c41be45e
commit
4ef219a8c1
2 changed files with 21 additions and 3 deletions
|
@ -5,12 +5,17 @@ import javafx.application.Application
|
|||
import javafx.fxml.FXMLLoader
|
||||
import javafx.scene.Scene
|
||||
import javafx.stage.Stage
|
||||
import java.util.logging.Logger
|
||||
|
||||
class MainPage : Application() {
|
||||
private val logger: Logger = Logger.getLogger("MainPage")
|
||||
|
||||
private lateinit var fxmlLoader: FXMLLoader
|
||||
|
||||
override fun start(stage: Stage) {
|
||||
ImageTagsPrediction.getInstance()
|
||||
|
||||
val fxmlLoader = FXMLLoader(MainPage::class.java.getResource("main-window-view.fxml"))
|
||||
fxmlLoader = FXMLLoader(MainPage::class.java.getResource("main-window-view.fxml"))
|
||||
val scene = Scene(fxmlLoader.load(), 640.0, 760.0)
|
||||
stage.title = "Image Tagger"
|
||||
stage.scene = scene
|
||||
|
@ -18,6 +23,12 @@ class MainPage : Application() {
|
|||
stage.minHeight = 760.0
|
||||
stage.show()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
logger.info("Stop called.")
|
||||
val controller = fxmlLoader.getController<MainPageController>()
|
||||
controller.shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
|
|
@ -18,6 +18,8 @@ import javax.imageio.ImageIO
|
|||
|
||||
|
||||
class MainPageController {
|
||||
private val logger: Logger = Logger.getLogger("MainPageController")
|
||||
|
||||
/**
|
||||
* The thread pool worker pool.
|
||||
*/
|
||||
|
@ -49,8 +51,6 @@ class MainPageController {
|
|||
private val imageTagsPrediction = ImageTagsPrediction.getInstance()
|
||||
|
||||
|
||||
private val logger: Logger = Logger.getLogger("MainPageController")
|
||||
|
||||
@FXML
|
||||
private lateinit var progressBar: ProgressBar
|
||||
|
||||
|
@ -143,4 +143,11 @@ class MainPageController {
|
|||
logger.info("Finished processing images.")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the MainPageController.
|
||||
*/
|
||||
fun shutdown() {
|
||||
workerPool.shutdownNow()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue