From e98eb83bad8162aa8777a2a9fcc3641e111a3840 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Fri, 22 Sep 2023 16:40:12 +0200 Subject: [PATCH] CoapClient - Added new `onNoNewMessages()` - Removed `watch()` --- source/doap/client/client.d | 38 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/source/doap/client/client.d b/source/doap/client/client.d index d4ca3b4..32598c5 100644 --- a/source/doap/client/client.d +++ b/source/doap/client/client.d @@ -236,32 +236,28 @@ public class CoapClient // private Duration sweepInterval; private Duration retransmitTimeout; - private void watch() + /** + * The intention of this method is that + * some kind-of `CoapMessagingLayer` + * can call this when it has no new + * messages to process. + * + * This then let's the client handle + * the checking of potentially timed + * out requests, and the re-issueing + * of them to the messaging layer. + */ + package void onNoNewMessages() { - while(true) + requestsLock.lock(); + foreach(CoapRequest curReq; outgoingRequests) { - // TODO: Sleep on a - - /** - * Acquire the requests lock so we - * can sleep on the condition - * (temporarily unlock mutex) - */ - // requestsLock.lock(); - // watcherSignal.wait(); - - requestsLock.lock(); - foreach(CoapRequest curReq; outgoingRequests) + if(curReq.hasTimedOut(retransmitTimeout)) { - if(curReq.hasTimedOut(retransmitTimeout)) - { - // TODO: Retransmit - } + // TODO: Retransmit } - requestsLock.unlock(); - - Thread.sleep(retransmitTimeout); } + requestsLock.unlock(); } }