summaryrefslogtreecommitdiff
path: root/rts/win32
diff options
context:
space:
mode:
authorDouglas Wilson <douglas.wilson@gmail.com>2021-01-04 09:46:58 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-17 05:49:54 -0500
commit33fc453fd46e54410472a7bad7585e5d1821c0ec (patch)
tree948b2b5af172fcac62364c656e71b70af4ce0bde /rts/win32
parent345ae06b3334a64e9d6db9ea69573ef3227e535a (diff)
downloadhaskell-33fc453fd46e54410472a7bad7585e5d1821c0ec.tar.gz
rts: add timedWaitCondition
Diffstat (limited to 'rts/win32')
-rw-r--r--rts/win32/OSThreads.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/rts/win32/OSThreads.c b/rts/win32/OSThreads.c
index ed8a598e51..07b0e3f034 100644
--- a/rts/win32/OSThreads.c
+++ b/rts/win32/OSThreads.c
@@ -559,6 +559,16 @@ waitCondition ( Condition* pCond, Mutex* pMut )
return true;
}
+bool
+timedWaitCondition ( Condition* pCond, Mutex* pMut, Time timeout )
+{
+ // If we pass a timeout of 0 SleepConditionVariableSRW will return immediately
+ // https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-sleepconditionvariablesrw
+ DWORD ms = (DWORD)stg_min(1, TimeToMS(timeout));
+ SleepConditionVariableSRW(pCond, pMut, ms, 0);
+ return true;
+}
+
void
initMutex (Mutex* pMut)
{