From 4fceb6ceb070358f7c641ad4e23c3e83a659d763 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 12 Nov 2015 16:28:11 -0400 Subject: make LockPool's LockHandle be able to support multiple different types of file locks --- Utility/LockPool/Windows.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Utility/LockPool/Windows.hs') diff --git a/Utility/LockPool/Windows.hs b/Utility/LockPool/Windows.hs index a88525a9b..2641ac37d 100644 --- a/Utility/LockPool/Windows.hs +++ b/Utility/LockPool/Windows.hs @@ -24,7 +24,7 @@ import Utility.LockPool.STM (LockFile, LockMode(..)) lockShared :: LockFile -> IO (Maybe LockHandle) lockShared file = tryMakeLockHandle (P.tryTakeLock P.lockPool file LockShared) - (F.lockShared file) + (fmap mk <$> F.lockShared file) {- Tries to take an exclusive lock on a file. Fails if another process has - a shared or exclusive lock. @@ -35,9 +35,14 @@ lockShared file = tryMakeLockHandle lockExclusive :: LockFile -> IO (Maybe LockHandle) lockExclusive file = tryMakeLockHandle (P.tryTakeLock P.lockPool file LockExclusive) - (F.lockExclusive file) + (fmap mk <$> F.lockExclusive file) {- If the initial lock fails, this is a BUSY wait, and does not - guarentee FIFO order of waiters. In other news, Windows is a POS. -} waitToLock :: IO (Maybe lockhandle) -> IO lockhandle waitToLock = F.waitToLock + +mk :: F.LockHandle -> FileLockOps +mk h = FileLockOps + { fDropLock = F.dropLock h + } -- cgit v1.2.3