refactor
This commit is contained in:
parent
0f25a7365a
commit
7bd9e33b84
3 changed files with 7 additions and 7 deletions
|
@ -10,6 +10,7 @@
|
|||
module Utility.LockPool.LockHandle where
|
||||
|
||||
import qualified Utility.LockPool.STM as P
|
||||
import Utility.LockPool.STM (LockFile)
|
||||
|
||||
import Control.Concurrent.STM
|
||||
import Control.Exception
|
||||
|
@ -22,13 +23,18 @@ data LockHandle = LockHandle
|
|||
data FileLockOps = FileLockOps
|
||||
{ fDropLock :: IO ()
|
||||
#ifndef mingw32_HOST_OS
|
||||
, fCheckSaneLock :: FilePath -> IO Bool
|
||||
, fCheckSaneLock :: LockFile -> IO Bool
|
||||
#endif
|
||||
}
|
||||
|
||||
dropLock :: LockHandle -> IO ()
|
||||
dropLock h = P.releaseLock (poolHandle h) (fDropLock (fileLockOps h))
|
||||
|
||||
#ifndef mingw32_HOST_OS
|
||||
checkSaneLock :: LockFile -> LockHandle -> IO Bool
|
||||
checkSaneLock lockfile (LockHandle _ flo) = fCheckSaneLock flo lockfile
|
||||
#endif
|
||||
|
||||
-- Take a lock, by first updating the lock pool, and then taking the file
|
||||
-- lock. If taking the file lock fails for any reason, take care to
|
||||
-- release the lock in the lock pool.
|
||||
|
|
|
@ -53,9 +53,6 @@ getLockStatus file = P.getLockStatus P.lockPool file
|
|||
(StatusLockedBy <$> getProcessID)
|
||||
(F.getLockStatus file)
|
||||
|
||||
checkSaneLock :: LockFile -> LockHandle -> IO Bool
|
||||
checkSaneLock lockfile (LockHandle _ flo) = fCheckSaneLock flo lockfile
|
||||
|
||||
mk :: F.LockHandle -> FileLockOps
|
||||
mk h = FileLockOps
|
||||
{ fDropLock = F.dropLock h
|
||||
|
|
|
@ -67,9 +67,6 @@ getLockStatus file = P.getLockStatus P.lockPool file
|
|||
(StatusLockedBy <$> getProcessID)
|
||||
(F.getLockStatus file)
|
||||
|
||||
checkSaneLock :: LockFile -> LockHandle -> IO Bool
|
||||
checkSaneLock lockfile (LockHandle _ flo) = fCheckSaneLock flo lockfile
|
||||
|
||||
mk :: F.LockHandle -> FileLockOps
|
||||
mk h = FileLockOps
|
||||
{ fDropLock = F.dropLock h
|
||||
|
|
Loading…
Reference in a new issue