-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | thread-friendly file locks that don't block the entire program
--
-- This module provides file locks that (unlike their counterparts in
-- System.Posix.IO) leave other threads running while one waits for the
-- lock.
@package colock
@version 0.2.2
-- | System.IO.Lock provides thread-friendly file locks. The locking
-- functions in System.Posix.IO (actually, it's just
-- System.Posix.IO.waitToSetLock) will block the entire program,
-- not just the calling thread (even with the threaded runtime). This
-- module avoids the problem by spawning a new process for each lock and
-- communicating with it over pipes.
--
-- Advantages:
--
--
-- - Only blocks the calling thread
-- - Works both with and without -threaded
--
--
-- Disadvantages:
--
--
-- - Forks one new process per lock
-- - Consumes one file descriptor per lock
--
--
-- Oddities:
--
--
-- - Closing the file descriptor doesn't affect the lock (because it's
-- really in a separate process); you must call unLock
-- instead.
--
module System.IO.Lock
data LockMode
LockRead :: LockMode
LockWrite :: LockMode
data LockDescriptor
-- | setLock locks the specified region of the file. It blocks the
-- calling thread until the lock is granted.
setLock :: Fd -> (LockMode, SeekMode, FileOffset, FileOffset) -> IO LockDescriptor
-- | setLockAll fd lm is equivalent to setLock
-- fd (lm, AbsoluteSeek, 0, 0). It locks the entire file, no
-- matter how big it is.
setLockAll :: Fd -> LockMode -> IO LockDescriptor
-- | unLock destroys the given lock.
unLock :: LockDescriptor -> IO ()
instance Typeable LockDescriptor
instance Typeable LockMode
instance Show LockDescriptor
instance Eq LockMode
instance Ord LockMode
instance Read LockMode
instance Show LockMode
instance Enum LockMode
instance Bounded LockMode