Added dependency on unbounded-delays
And stop vendoring part of it. This is a free dependency because tasty depends on it. Sponsored-by: Leon Schuermann on Patreon
This commit is contained in:
parent
cf1411fabe
commit
c2d6c02c27
4 changed files with 11 additions and 20 deletions
|
@ -1,7 +1,6 @@
|
|||
{- thread scheduling
|
||||
-
|
||||
- Copyright 2012, 2013 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2011 Bas van Dijk & Roel van Dijk
|
||||
- Copyright 2012-2024 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- License: BSD-2-clause
|
||||
-}
|
||||
|
@ -20,6 +19,7 @@ module Utility.ThreadScheduler (
|
|||
|
||||
import Control.Monad
|
||||
import Control.Concurrent
|
||||
import qualified Control.Concurrent.Thread.Delay as Unbounded
|
||||
#ifndef mingw32_HOST_OS
|
||||
import Control.Monad.IfElse
|
||||
import System.Posix.IO
|
||||
|
@ -44,20 +44,9 @@ runEvery n a = forever $ do
|
|||
threadDelaySeconds :: Seconds -> IO ()
|
||||
threadDelaySeconds (Seconds n) = unboundDelay (fromIntegral n * oneSecond)
|
||||
|
||||
{- Like threadDelay, but not bounded by an Int.
|
||||
-
|
||||
- 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.
|
||||
-
|
||||
- Taken from the unbounded-delay package to avoid a dependency for 4 lines
|
||||
- of code.
|
||||
-}
|
||||
{- Like threadDelay, but not bounded by an Int. -}
|
||||
unboundDelay :: Microseconds -> IO ()
|
||||
unboundDelay time = do
|
||||
let maxWait = min time $ toInteger (maxBound :: Int)
|
||||
threadDelay $ fromInteger maxWait
|
||||
when (maxWait /= time) $ unboundDelay (time - maxWait)
|
||||
unboundDelay = Unbounded.delay
|
||||
|
||||
{- Pauses the main thread, letting children run until program termination. -}
|
||||
waitForTermination :: IO ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue