From 5c3c7315da50d7bcd862fefe1b80f7a84f75f584 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 20 May 2020 12:53:29 +0200 Subject: docs: Clarify ugly hack for caching Delay --- .../atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'opendc') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt index a0ca2347..6a77415c 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt @@ -267,10 +267,13 @@ public class SimpleBareMetalDriver( /** * Cache the [Clock] for timing. */ - private val clock= domain.coroutineContext[SimulationContext]!!.clock + private val clock = domain.coroutineContext[SimulationContext]!!.clock /** - * Cache the [Delay] instance for timing. Ugly hack which may break in the future. + * Cache the [Delay] instance for timing. + * + * XXX We need to cache this before the call to [onRun] since doing this in [onRun] is too heavy. + * XXX Note however that this is an ugly hack which may break in the future. */ @OptIn(InternalCoroutinesApi::class) private val delay = domain.coroutineContext[ContinuationInterceptor] as Delay @@ -290,8 +293,6 @@ public class SimpleBareMetalDriver( usageFlush?.dispose() usageFlush = null - val context = select.completion.context - val queue = batch.iterator() var start = Long.MIN_VALUE var currentWork: SliceWork? = null -- cgit v1.2.3