diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-11-12 17:12:54 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-11-12 17:12:54 -0400 |
commit | 00fdc3063fe586cdce35ba8dbe2f1b024479522c (patch) | |
tree | e6e593c87ceba3d5adcc27e53ded216e4cdb474a /Utility/LockPool | |
parent | d94a72a381baf0e251db48844d27755d5f2c8f14 (diff) |
add timeout for pid lock waiting
Diffstat (limited to 'Utility/LockPool')
-rw-r--r-- | Utility/LockPool/PidLock.hs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Utility/LockPool/PidLock.hs b/Utility/LockPool/PidLock.hs index dc796b961..dca353fdf 100644 --- a/Utility/LockPool/PidLock.hs +++ b/Utility/LockPool/PidLock.hs @@ -22,6 +22,7 @@ import Utility.LockFile.LockStatus import qualified Utility.LockPool.STM as P import Utility.LockPool.STM (LockFile, LockMode(..)) import Utility.LockPool.LockHandle +import Utility.ThreadScheduler import System.IO import System.Posix @@ -29,13 +30,11 @@ import Data.Maybe import Control.Applicative import Prelude --- Takes a pid lock, blocking until the lock is available. --- --- May block forever on stale locks, see PidLock documentation for details. -waitLock :: LockFile -> IO LockHandle -waitLock file = makeLockHandle +-- Takes a pid lock, blocking until the lock is available or the timeout. +waitLock :: Seconds -> LockFile -> IO LockHandle +waitLock timeout file = makeLockHandle (P.waitTakeLock P.lockPool file LockExclusive) - (mk <$> F.waitLock file) + (mk <$> F.waitLock timeout file) -- Tries to take a pid lock, but does not block. tryLock :: LockFile -> IO (Maybe LockHandle) |