From 6b56aadfee60db8a79eaf3d5c68c0c400a8494ce Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Tue, 25 Aug 2026 09:31:14 +0200 Subject: [PATCH] Run Windows waitForSingleObject continuation in waiting thread > By default, the callback function is queued to a non-I/O worker thread https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-registerwaitforsingleobject Set `WT_EXECUTEINWAITTHREAD` when waiting for an object to avoid mixing up different threads. This is in line with `addProcess2` / `addSignal2`. --- chronos/internal/asyncfutures.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chronos/internal/asyncfutures.nim b/chronos/internal/asyncfutures.nim index c487b4ec..556da822 100644 --- a/chronos/internal/asyncfutures.nim +++ b/chronos/internal/asyncfutures.nim @@ -1618,7 +1618,7 @@ when defined(windows): async: (raises: [AsyncError, CancelledError], raw: true).} = ## Waits until the specified object is in the signaled state or the ## time-out interval elapses. WaitForSingleObject() for asynchronous world. - let flags = WT_EXECUTEONLYONCE + let flags = WT_EXECUTEINWAITTHREAD or WT_EXECUTEONLYONCE var retFuture = newFuture[WaitableResult]("chronos.waitForSingleObject()")