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
|
module Utility.LockPool.LockHandle where
|
||||||
|
|
||||||
import qualified Utility.LockPool.STM as P
|
import qualified Utility.LockPool.STM as P
|
||||||
|
import Utility.LockPool.STM (LockFile)
|
||||||
|
|
||||||
import Control.Concurrent.STM
|
import Control.Concurrent.STM
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
|
@ -22,13 +23,18 @@ data LockHandle = LockHandle
|
||||||
data FileLockOps = FileLockOps
|
data FileLockOps = FileLockOps
|
||||||
{ fDropLock :: IO ()
|
{ fDropLock :: IO ()
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
, fCheckSaneLock :: FilePath -> IO Bool
|
, fCheckSaneLock :: LockFile -> IO Bool
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
dropLock :: LockHandle -> IO ()
|
dropLock :: LockHandle -> IO ()
|
||||||
dropLock h = P.releaseLock (poolHandle h) (fDropLock (fileLockOps h))
|
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
|
-- 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
|
-- lock. If taking the file lock fails for any reason, take care to
|
||||||
-- release the lock in the lock pool.
|
-- release the lock in the lock pool.
|
||||||
|
|
|
@ -53,9 +53,6 @@ getLockStatus file = P.getLockStatus P.lockPool file
|
||||||
(StatusLockedBy <$> getProcessID)
|
(StatusLockedBy <$> getProcessID)
|
||||||
(F.getLockStatus file)
|
(F.getLockStatus file)
|
||||||
|
|
||||||
checkSaneLock :: LockFile -> LockHandle -> IO Bool
|
|
||||||
checkSaneLock lockfile (LockHandle _ flo) = fCheckSaneLock flo lockfile
|
|
||||||
|
|
||||||
mk :: F.LockHandle -> FileLockOps
|
mk :: F.LockHandle -> FileLockOps
|
||||||
mk h = FileLockOps
|
mk h = FileLockOps
|
||||||
{ fDropLock = F.dropLock h
|
{ fDropLock = F.dropLock h
|
||||||
|
|
|
@ -67,9 +67,6 @@ getLockStatus file = P.getLockStatus P.lockPool file
|
||||||
(StatusLockedBy <$> getProcessID)
|
(StatusLockedBy <$> getProcessID)
|
||||||
(F.getLockStatus file)
|
(F.getLockStatus file)
|
||||||
|
|
||||||
checkSaneLock :: LockFile -> LockHandle -> IO Bool
|
|
||||||
checkSaneLock lockfile (LockHandle _ flo) = fCheckSaneLock flo lockfile
|
|
||||||
|
|
||||||
mk :: F.LockHandle -> FileLockOps
|
mk :: F.LockHandle -> FileLockOps
|
||||||
mk h = FileLockOps
|
mk h = FileLockOps
|
||||||
{ fDropLock = F.dropLock h
|
{ fDropLock = F.dropLock h
|
||||||
|
|
Loading…
Reference in a new issue