Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Node.DbLock
Contents
Synopsis
- newtype DbLocked = DbLocked FilePath
- withLockDB :: MountPoint -> IO a -> IO a
- dbLockFsPath :: FsPath
- dbLockTimeout :: DiffTime
- withLockDB_ :: forall m a. ( IOLike m, MonadTimer m) => FileLock m -> MountPoint -> FsPath -> DiffTime -> m a -> m a
Documentation
Instances
Eq DbLocked Source # | |
Show DbLocked Source # | |
Exception DbLocked Source # | |
Defined in Ouroboros.Consensus.Node.DbLock Methods toException :: DbLocked -> SomeException Source # fromException :: SomeException -> Maybe DbLocked Source # displayException :: DbLocked -> String Source # |
withLockDB :: MountPoint -> IO a -> IO a Source #
We use an empty file (
dbLockFsPath
) as a lock of the database so that
the database cannot be opened by more than one process. We wait up to
dbLockTimeout
to take the lock, before timing out and throwing a
DbLocked
exception.
Defaults
dbLockFsPath :: FsPath Source #
The default lock file
dbLockTimeout :: DiffTime Source #
Default time to wait on the lock
For testing purposes
Arguments
:: forall m a. ( IOLike m, MonadTimer m) | |
=> FileLock m | |
-> MountPoint |
Root of the path |
-> FsPath |
File to lock |
-> DiffTime |
Timeout |
-> m a | |
-> m a |
We use the given
FsPath
in the
MountPoint
as a lock of the database
so that the database cannot be opened by more than one process. We wait the
given
DiffTime
on the thread taking the lock. In case of a timeout, we
throw a
DbLocked
exception.
Some systems may delete the empty file when all its handles are closed. This is not an issue, since the file is created if it doesn't exist.