Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
Open Handle
based locking
Synopsis
- data FileLockingNotSupported = FileLockingNotSupported
- fileLockingSupported :: Bool
- type FileLockingSupported = True
- data FileLockingMethod
- fileLockingMethod :: FileLockingMethod
- data LockMode
- type FD = FD
- fdOpen :: FilePath -> IO FD
- fdClose :: FD -> IO ()
- fdLock :: FD -> LockMode -> IO ()
- fdTryLock :: FD -> LockMode -> IO Bool
- fdUnlock :: FD -> IO ()
- handleToFd :: Handle -> IO FD
- hLock :: Handle -> LockMode -> IO ()
- hTryLock :: Handle -> LockMode -> IO Bool
- hUnlock :: Handle -> IO ()
Documentation
data FileLockingNotSupported Source #
Exception thrown by hLock
on non-Windows platforms that don't support
flock
.
Instances
Exception FileLockingNotSupported Source # | |
Show FileLockingNotSupported Source # | |
Defined in Lukko.Internal.Types showsPrec :: Int -> FileLockingNotSupported -> ShowS # show :: FileLockingNotSupported -> String # showList :: [FileLockingNotSupported] -> ShowS # |
fileLockingSupported :: Bool Source #
A constants specifying whether file locking is supported.
type FileLockingSupported = True Source #
A type level fileLockingSupported
.
data FileLockingMethod Source #
Potentially availble lock methods.
MethodOFD | open file descriptor locking |
MethodFLock | BSD |
MethodWindows | Windows locking |
MethodNoOp | No-Op (throws |
Instances
fileLockingMethod :: FileLockingMethod Source #
A constant specifying this method
File descriptors
Handles
hLock :: Handle -> LockMode -> IO () Source #
If a Handle
references a file descriptor, attempt to lock contents of the
underlying file in appropriate mode. If the file is already locked in
incompatible mode, this function blocks until the lock is established. The
lock is automatically released upon closing a Handle
.
Things to be aware of:
1) This function may block inside a C call. If it does, in order to be able to interrupt it with asynchronous exceptions and/or for other threads to continue working, you MUST use threaded version of the runtime system.
2) The implementation uses LockFileEx
on Windows,
open file descriptor locks on Linux, and flock
otherwise,
hence all of their caveats also apply here.
3) On non-Windows plaftorms that don't support flock
(e.g. Solaris) this
function throws FileLockingNotImplemented
. We deliberately choose to not
provide fcntl
based locking instead because of its broken semantics.