Documentation ¶
Overview ¶
Package lock implements simple locking primitives on a directory using flock
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DirLock ¶
type DirLock struct {
// contains filtered or unexported fields
}
DirLock represents a lock on a directory
func ExclusiveLock ¶
ExclusiveLock takes an exclusive lock on a directory. It will block if an exclusive lock is already held on the directory.
func SharedLock ¶
SharedLock takes a co-operative (shared) lock on a directory. It will block if an exclusive lock is already held on the directory.
func TryExclusiveLock ¶
TryExclusiveLock takes an exclusive lock on a directory without blocking. It will return ErrLocked if any lock is already held on the directory.
func TrySharedLock ¶
TrySharedLock takes a co-operative (shared) lock on a directory without blocking. It will return ErrLocked if an exclusive lock already exists on the directory.
func (*DirLock) ExclusiveLock ¶
ExclusiveLock takes an exclusive lock on a directory. This is idempotent when the DirLock already represents an exclusive lock, and promotes a shared lock to exclusive atomically. It will block if an exclusive lock is already held on the directory.
func (*DirLock) SharedLock ¶
SharedLock takes a co-operative (shared) lock on a directory. This is idempotent when the DirLock already represents a shared lock, and demotes an exclusive lock to shared atomically. It will block if an exclusive lock is already held on the directory.
func (*DirLock) TryExclusiveLock ¶
TryExclusiveLock takes an exclusive lock on a directory without blocking. This is idempotent when the DirLock already represents an exclusive lock, and tries promote a shared lock to exclusive atomically. It will return ErrLocked if any lock is already held on the directory.
func (*DirLock) TrySharedLock ¶
TrySharedLock takes a co-operative (shared) lock on a directory without blocking. This is idempotent when the DirLock already represents a shared lock, and tries demote an exclusive lock to shared atomically. It will return ErrLocked if an exclusive lock already exists on the directory.