Documentation
¶
Overview ¶
Package flock wraps the BSD advisory whole-file lock (flock(2)) so a consumer can serialise mutually-exclusive work across processes that share a lock file - e.g. one warm-cache writer at a time. The lock is advisory: it only constrains cooperating processes that also call here.
Exclusive blocks until it holds the lock; Unlock releases it. Both take the *os.File the caller opened on the shared lock path and keep open for the lock's lifetime.
Locking is unix-only. A non-unix caller is refused with ErrUnsupported rather than handed a no-op that reports success.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("flock: advisory file locking is unix-only")
ErrUnsupported reports that this platform has no advisory file locking, so no lock was taken. Distinct from contention: nobody else holds it.
Functions ¶
func Exclusive ¶
Exclusive takes a blocking exclusive (LOCK_EX) advisory lock on f, held until Unlock or f is closed. Non-unix returns ErrUnsupported.
Types ¶
This section is empty.