From eca08ef49a049f3bce53707b434f4bb200ce99aa Mon Sep 17 00:00:00 2001
From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de>
Date: Wed, 15 Dec 2021 15:09:37 +0100
Subject: [PATCH] run the benchmark checker in dedicated thread

---
 .../execution/operator/BenchmarkStateChecker.kt        | 10 ++++++++++
 .../execution/operator/TheodoliteController.kt         |  3 +--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateChecker.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateChecker.kt
index a889b9c7a..e21366ce6 100644
--- a/theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateChecker.kt
+++ b/theodolite/src/main/kotlin/theodolite/execution/operator/BenchmarkStateChecker.kt
@@ -18,6 +18,16 @@ class BenchmarkStateChecker(
     private val client: NamespacedKubernetesClient
 
 ) {
+
+    fun start(running: Boolean) {
+        Thread {
+            while (running) {
+                updateBenchmarkStatus()
+                Thread.sleep(100 * 1)
+            }
+        }.start()
+    }
+
     /**
      * Checks and updates the states off all deployed benchmarks.
      *
diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt
index e6fb2eada..ff5e769d6 100644
--- a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt
+++ b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt
@@ -41,7 +41,7 @@ class TheodoliteController(
         sleep(5000) // wait until all states are correctly set
         while (true) {
             reconcile()
-            benchmarkSateChecker.updateBenchmarkStatus()
+            benchmarkSateChecker.start(true)
             sleep(2000)
         }
     }
@@ -49,7 +49,6 @@ class TheodoliteController(
     private fun reconcile() {
         do {
             val execution = getNextExecution()
-            benchmarkSateChecker.updateBenchmarkStatus()
             if (execution != null) {
                 val benchmark = getBenchmarks()
                     .map { it.spec }
-- 
GitLab