cmd/go/internal/lockedfile: add package and support library
lockedfile.File passes through to os.File, with Open, Create, and OpenFile functions that mimic the corresponding os functions but acquire locks automatically, releasing them when the file is closed. lockedfile.Sentinel is a simplified wrapper around lockedfile.OpenFile for the common use-case of files that signal the status of idempotent tasks. lockedfile.Mutex is a Mutex-like synchronization primitive implemented in terms of file locks. lockedfile.Read is like ioutil.Read, but obtains a read-lock. lockedfile.Write is like ioutil.Write, but obtains a write-lock and can be used for read-only files with idempotent contents. Updates #26794 Change-Id: I50f7132c71d2727862eed54411f3f27e1af55cad Reviewed-on: https://go-review.googlesource.com/c/145178 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
Showing
Please register or sign in to comment