Skip to content
FutureBlitz

    Install

    Import std.io.lock

    std.io.lock

    std.io's file locks: a FileLock holds a lock on a file, which another FileLock, in this program or another, waits for, or is refused, until it's closed. Locks only keep other locks out: on every OS, anyone can still read and write the file.

    std/io/lock.fb

    Types

    FileLock class

    Public Class FileLock

    A lock on a file, held for this FileLock alone, or shared with other shared ones, until Close, or until its last reference goes. The file is made, empty, when it isn't there, and stays when the lock goes. A FileLock waiting for one that this program holds waits forever.

    std/io/lock.fb, line 22

    • Public ReadOnly Field Path: Path field #

      The file it locks.

    • Public ReadOnly Field IsShared: Bool field #

      Whether it's a shared lock, which other shared ones can hold too, or an exclusive one.

    • Public Static Method Acquire(path: Path): FileLock Throws IOError static method #

      A lock on the file for this one alone, once no other holds one.

    • Public Static Async Method AcquireAsync(path: Path): FileLock Throws IOError static method #

      What Acquire does, without blocking its thread: a call gives its Task.

    • Public Static Method AcquireShared(path: Path): FileLock Throws IOError static method #

      A lock on the file that other shared ones can hold too, once no lock for one alone holds it.

    • Public Static Async Method AcquireSharedAsync(path: Path): FileLock Throws IOError static method #

      What AcquireShared does, without blocking its thread: a call gives its Task.

    • Public Static Method TryAcquire(path: Path): FileLock? Throws IOError static method #

      A lock for this one alone, or Null when another holds one now.

    • Public Static Method TryAcquireShared(path: Path): FileLock? Throws IOError static method #

      A shared lock, or Null when a lock for one alone holds the file now.

    • Public Method IsHeld(): Bool method #

      Whether it still holds its lock.

    • Public Method Close() method #

      Lets go of the lock, which a second Close leaves alone.

    Report an issue with this page or with FutureBlitz on GitHub.