~/bend-docscommunity

src/DbLock.bend relies on unsafe/foreign

raw source on the hub · import mylsm-lsm-store@0.5.0.0/src/DbLock.bend as DbLock

3 imports
import Base
import ./DurableError.bend as DurableError
import ./DbLockPolicy.bend as Policy

Types

type Lock source · line 6 · raw

Type

Owns the open LOCK file until release.

Definitions

def lock_path source · line 10 · raw

@path:String -> String

Builds the stable LOCK path for a database directory.

def open_failed source · line 22 · raw

@error:Pair(U32, String) -> @operation:String -> @path:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Lock>)

Classifies a failure to open the LOCK file.

def lock_failed source · line 29 · raw

@file:File -> @error:Pair(U32, String) -> @operation:String -> @path:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Lock>)

Closes the file and classifies a failed lock attempt.

def lock_result source · line 42 · raw

@pair:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> @operation:String -> @path:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Lock>)

Returns an owned lock on success or closes the failed handle.

def lock_file source · line 54 · raw

@file:File -> @operation:String -> @path:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Lock>)

Attempts the nonblocking OS lock on the open file.

def opened source · line 60 · raw

@result:Result<&1, &1, Pair(U32, String), File> -> @operation:String -> @path:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Lock>)

Locks the opened file or classifies its open error.

def acquire source · line 72 · raw

@+path:String -> @operation:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Lock>)

Opens the stable LOCK file and acquires its OS lock.

def release_failed source · line 78 · raw

@file:File -> @error:Pair(U32, String) -> @operation:String -> @path:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Unit>)

Closes the file and preserves the unlock error.

def release_succeeded source · line 91 · raw

@file:File -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Unit>)

Closes the file after a successful unlock.

def released source · line 97 · raw

@pair:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> @operation:String -> @path:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Unit>)

Closes the file after either unlock result.

def unlock_file source · line 109 · raw

@file:File -> @operation:String -> @path:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Unit>)

Unlocks the file and closes it after the result.

def release source · line 115 · raw

@lock:Lock -> @operation:String -> @path:String -> IO(Result<&1, &1, 0x4fcd94fa965aa1443134557fd075a483/src/DurableError.Error, Unit>)

Consumes the lock and releases its file handle.

Effects (foreign code)

effect DbLock.try_lock source · line 13 · raw

@file:File -> IO(Pair(File, Result<&1, &1, Pair(U32, String), Unit>))

foreign: src/effs/db_lock.c, src/effs/db_lock.js

effect DbLock.try_unlock source · line 17 · raw

@file:File -> IO(Pair(File, Result<&1, &1, Pair(U32, String), Unit>))

foreign: src/effs/db_unlock.c, src/effs/db_unlock.js