def acquire
import cswap-bend-cli@0.1.0.0/lock.bend as Lockimport Base
import cswap-bend-cli@0.1.0.0/fs.bend as Fs
import cswap-bend-cli@0.1.0.0/fs/write.bend as FsW
79# Take the lock at `path`, waiting up to `timeout_ms`. Done{Some{file}} holds
80# it (pass the file to `release`); Done{None} means the wait timed out.
81# Creates missing parent directories and truncates the lock file, as the
82# reference does.
83def acquire(+path: String, timeout_ms: U32) -> IO(Fs.Res(Maybe<&1, File>)):
84 IO.bind(Fs.Res(Unit), Fs.Res(Maybe<&1, File>), FsW.mkdir_p(Fs.dirname(path)),
85 r => parent.ok(r, timeout_ms, path))