From 460840fad35e711c183428be6f3be48838333310 Mon Sep 17 00:00:00 2001 From: Robinson Date: Fri, 17 Mar 2023 14:58:04 +0100 Subject: [PATCH] PING cancelRequest now uses send(), so that events are processed in order (instead of concurrently) --- src/dorkbox/network/rmi/ResponseManager.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dorkbox/network/rmi/ResponseManager.kt b/src/dorkbox/network/rmi/ResponseManager.kt index 6b7e7f1f..35323d2f 100644 --- a/src/dorkbox/network/rmi/ResponseManager.kt +++ b/src/dorkbox/network/rmi/ResponseManager.kt @@ -183,8 +183,8 @@ internal class ResponseManager(maxValuesInCache: Int = 65535, minimumValue: Int /** * Cancels the RMI request in the given timeout, the callback is executed inside the read lock */ - fun cancelRequest(eventDispatch: EventDispatcher, timeoutMillis: Long, id: Int, logger: KLogger, onCancelled: ResponseWaiter.() -> Unit) { - eventDispatch.launch { + suspend fun cancelRequest(eventDispatch: EventDispatcher, timeoutMillis: Long, id: Int, logger: KLogger, onCancelled: ResponseWaiter.() -> Unit) { + eventDispatch.send { delay(timeoutMillis) // this will always wait. if this job is cancelled, this will immediately stop waiting // check if we have a result or not