From c2d6c02c272fb4fa675fdbd2e1fcb2b8fd1cb617 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 27 Feb 2024 13:11:59 -0400 Subject: [PATCH] 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 --- CHANGELOG | 6 ++++++ COPYRIGHT | 5 ----- Utility/ThreadScheduler.hs | 19 ++++--------------- git-annex.cabal | 1 + 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 05ecb54c62..2f454f0a19 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +git-annex (10.20240228) UNRELEASED; urgency=medium + + * Added dependency on unbounded-delays. + + -- Joey Hess Tue, 27 Feb 2024 13:07:10 -0400 + git-annex (10.20240227) upstream; urgency=medium * importfeed: Added --scrape option, which uses yt-dlp to screen scrape diff --git a/COPYRIGHT b/COPYRIGHT index c047f4173e..a41e2d603a 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -33,11 +33,6 @@ Copyright: © 2011-2020 Joey Hess © 2014 Robie Basak License: GPL-3+ -Files: Utility/ThreadScheduler.hs -Copyright: 2011 Bas van Dijk & Roel van Dijk - 2012, 2013 Joey Hess -License: BSD-2-clause - Files: Utility/Attoparsec.hs Copyright: 2019 Joey Hess 2007-2015 Bryan O'Sullivan diff --git a/Utility/ThreadScheduler.hs b/Utility/ThreadScheduler.hs index 9ab94d911e..245605b0b4 100644 --- a/Utility/ThreadScheduler.hs +++ b/Utility/ThreadScheduler.hs @@ -1,7 +1,6 @@ {- thread scheduling - - - Copyright 2012, 2013 Joey Hess - - Copyright 2011 Bas van Dijk & Roel van Dijk + - Copyright 2012-2024 Joey Hess - - 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 () diff --git a/git-annex.cabal b/git-annex.cabal index fea72b95dd..448ae067fb 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -267,6 +267,7 @@ Executable git-annex split, attoparsec (>= 0.13.2.2), concurrent-output (>= 1.10), + unbounded-delays, QuickCheck (>= 2.10.0), tasty (>= 1.2), tasty-hunit,