def wait

cswap-bend-cli@0.1.0.0 · lock.bend:37

import cswap-bend-cli@0.1.0.0/lock.bend as Lock
import Base
import cswap-bend-cli@0.1.0.0/fs.bend as Fs

37# Retry `fuel` more times, 100 ms apart, until the lock is held.
38def wait(fuel: Nat, fr: File & Fs.Res(Bool)) -> IO(File & Fs.Res(Bool)):
39  match fuel fr:
40    case 1n++p Tuple{f, Done{False{}}}:
41      IO.bind(Unit, File & Fs.Res(Bool), IO.sleep(poll_ms()),
42        u => IO.bind(File & Fs.Res(Bool), File & Fs.Res(Bool), attempt(f), r => wait(p, r)))
43    case _ _:
44      IO.pure(File & Fs.Res(Bool), fr)

Uses (14)

Used by (1)