diff options
author | Bodigrim <andrew.lelechenko@gmail.com> | 2022-08-10 20:29:25 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-08-10 22:41:50 -0400 |
commit | 5c24b1b3a9d6a4c2f471fd7d8ec65141a8b46357 (patch) | |
tree | a9aca8e33c9df8b7ef701b033b245e5be7c758a0 /libraries/base/GHC/Event/Thread.hs | |
parent | 45eb4cbe372eadb8331c6dbc84f14c681b1a8a9b (diff) | |
download | haskell-5c24b1b3a9d6a4c2f471fd7d8ec65141a8b46357.tar.gz |
Document that threadDelay / timeout are susceptible to overflows on 32-bit machines
Diffstat (limited to 'libraries/base/GHC/Event/Thread.hs')
-rw-r--r-- | libraries/base/GHC/Event/Thread.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libraries/base/GHC/Event/Thread.hs b/libraries/base/GHC/Event/Thread.hs index cf9a769766..4f67a97513 100644 --- a/libraries/base/GHC/Event/Thread.hs +++ b/libraries/base/GHC/Event/Thread.hs @@ -55,6 +55,10 @@ import System.Posix.Types (Fd) -- There is no guarantee that the thread will be rescheduled promptly -- when the delay has expired, but the thread will never continue to -- run /earlier/ than specified. +-- +-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only +-- 2147483647 μs, less than 36 minutes. +-- threadDelay :: Int -> IO () threadDelay usecs = mask_ $ do mgr <- getSystemTimerManager @@ -65,6 +69,9 @@ threadDelay usecs = mask_ $ do -- | Set the value of returned TVar to True after a given number of -- microseconds. The caveats associated with threadDelay also apply. -- +-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only +-- 2147483647 μs, less than 36 minutes. +-- registerDelay :: Int -> IO (TVar Bool) registerDelay usecs = do t <- atomically $ newTVar False |