Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type T ¶
T wraps flock and dumps JSON data in the lock file hinting about what holds the lock.
func (*T) Lock ¶
Lock acquires an exclusive file lock on the file and writes a JSON formatted structure hinting who holds the lock and with what intention.
func (*T) Probe ¶ added in v1.1.0
Probe attempts to acquire a file lock. If successful, it releases the lock and returns an empty Meta. If the lock is already held by another process, it reads and returns the current lock metadata. Note: Reading the metadata may fail if the other process has not finished writing it.
func (*T) UnLock ¶
UnLock releases the file lock acquired by Lock, and empties the lock file of its holder.
The lock file is kept, not removed: a lock is one of the file, not of its path, and a process opening the file before its removal would lock it once released, while another one creates a new file at the path and locks it, both holding the lock.
The file of the Locker is closed, and a new Locker replaces it: a lock is one of the process on the file, released when any of its descriptors of the file closes, and the file of a Locker unlocked but left open, closed later as it is collected, would release the lock of another Locker of the process holding it.