dirlock.bend relies on unsafe/foreign
raw source on the hub · import cswap-bend-cli@0.1.0.0/dirlock.bend as Dirlock
5 imports
import Base import ./fs.bend as Fs import ./act.bend as Act import ./clock.bend as Clock import ./fs/write.bend as FsW
Definitions
def ActM source · line 14 · raw
@-A:Type -> Type
def ActM.pure source · line 17 · raw
@-A:Type -> @x:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(A)
def ActM.bind source · line 20 · raw
@-A:Type -> @-B:Type -> @m:0x0717344745a30ebad1f19045228e8f18/act.of(A) -> @f:(@_:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)) -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)
def poll_ms source · line 28 · raw
U32
def mkdir_ok source · line 31 · raw
@r:0x0717344745a30ebad1f19045228e8f18/fs.Res(String) -> 0x0717344745a30ebad1f19045228e8f18/fs.Res(Bool)
def take_once source · line 39 · raw
@+dir:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Bool)
One attempt: mkdir without -p, so it fails while the lock is held.
def stale_of source · line 42 · raw
@m:Result<&1, &1, Pair(U32, String), U32> -> @+now:U32 -> @+staleness:U32 -> Bool
def is_stale source · line 49 · raw
@+dir:String -> @+staleness:U32 -> 0x0717344745a30ebad1f19045228e8f18/act.of(Bool)
def reclaim source · line 55 · raw
@+stale:Bool -> @+dir:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def basename source · line 58 · raw
@+p:String -> String
def busy_msg source · line 61 · raw
@+dir:String -> String
def retake source · line 65 · raw
@+dir:String -> @+staleness:U32 -> 0x0717344745a30ebad1f19045228e8f18/act.of(Bool)
Take over a stale lock, wait a beat, try again.
def wait source · line 73 · raw
@+fuel:Nat -> @+dir:String -> @+staleness:U32 -> @+got:Bool -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
Wait for the lock fuel more times, taking over a stale one.
def tries source · line 84 · raw
@+timeout_ms:U32 -> Nat
def take source · line 88 · raw
@+dir:String -> @+timeout_ms:U32 -> @+staleness:U32 -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
Take the lock at dir (its parent is created), waiting up to timeout_ms.
def release source · line 94 · raw
@+dir:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def with_dirlock source · line 98 · raw
@-A:Type -> @+dir:String -> @+timeout_ms:U32 -> @+staleness:U32 -> @act:0x0717344745a30ebad1f19045228e8f18/act.of(A) -> 0x0717344745a30ebad1f19045228e8f18/act.of(A)
Hold the directory lock around act, released whatever act answers.
Effects (foreign code)
effect Dirlock.mtime source · line 24 · raw
@+path:String -> IO(Result<&1, &1, Pair(U32, String), U32>)
Modification time of a path in whole seconds.
foreign: effs/mtime.c, effs/mtime.js