File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
adapter/src/main/kotlin/org/javacs/ktda Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import org.javacs.kt.LogMessage
17
17
import org.javacs.kt.util.AsyncExecutor
18
18
import org.javacs.ktda.util.JSON_LOG
19
19
import org.javacs.ktda.util.KotlinDAException
20
- import org.javacs.ktda.util.waitUntil
20
+ import org.javacs.ktda.util.waitFor
21
21
import org.javacs.ktda.core.Debuggee
22
22
import org.javacs.ktda.core.DebugContext
23
23
import org.javacs.ktda.core.event.DebuggeeEventBus
@@ -114,7 +114,7 @@ class KotlinDebugAdapter(
114
114
// (LSP4J does currently not provide a mechanism to hook into the request/response machinery)
115
115
116
116
LOG .trace(" Waiting for configurationDoneResponse" )
117
- waitUntil { (configurationDoneResponse?.numberOfDependents ? : 0 ) != 0 }
117
+ waitFor( " configuration done response " ) { (configurationDoneResponse?.numberOfDependents ? : 0 ) != 0 }
118
118
LOG .trace(" Done waiting for configurationDoneResponse" )
119
119
}
120
120
@@ -373,7 +373,7 @@ class KotlinDebugAdapter(
373
373
}
374
374
375
375
private inline fun <T > onceDebuggeeIsPresent (body : (Debuggee ) -> T ): T {
376
- waitUntil { debuggee != null }
376
+ waitFor( " debuggee " ) { debuggee != null }
377
377
return body(debuggee!! )
378
378
}
379
379
Original file line number Diff line number Diff line change @@ -50,9 +50,19 @@ fun <T> nonNull(item: T?, errorMsgIfNull: String): T =
50
50
* Blocks the current thread until the condition becomes true.
51
51
* Checks are performed in 80 ms intervals.
52
52
*/
53
- inline fun waitUntil (condition : () -> Boolean ) {
53
+ inline fun waitFor (what : String , condition : () -> Boolean ) {
54
+ val delayUntilNotificationMs = 10_000
55
+ val startTime = System .currentTimeMillis()
56
+ var lastTime = startTime
57
+
54
58
while (! condition()) {
55
59
Thread .sleep(80 )
60
+
61
+ val now = System .currentTimeMillis()
62
+ if ((now - lastTime) > delayUntilNotificationMs) {
63
+ LOG .info(" Waiting for {} for {} seconds..." , what, (now - startTime) / 1000 )
64
+ lastTime = now
65
+ }
56
66
}
57
67
}
58
68
You can’t perform that action at this time.
0 commit comments