Skip to content
FutureBlitz

    Install

    Import std.concurrent.lazy

    Lazy

    std.concurrent.lazy

    class

    Public Shared Class Lazy<T: Sendable>

    A value made the first time a thread asks for it, once however many threads ask at once.

    Examples

    Const settings = Lazy<String>(Function() => "loaded")
    Expect(!settings.IsMade)
    Expect(settings.Value == "loaded")
    Expect(settings.IsMade)

    std/concurrent/lazy.fb, line 24

    • Public New(maker: Sendable Func(): T) constructor #

      A Lazy whose value maker makes, the first time Value is read.

    • @PanicsAtCaller Public Property Value: T property #

      The value, which the first read makes, on the thread that reads it, while the reads on other threads wait for it. Panics when the maker reads its own Lazy's Value, which would wait for itself forever.

    • Public Property IsMade: Bool property #

      Whether the value is made, which a thread that reads it while it's being made doesn't wait for.

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