⚡ ZIG ALCHEMY DIFFICULTY: Adept Creational

The Singleton: Monolith Binding

Ensure that only one instance of an ancient power source exists within the void.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Abjuration // Monolith Binding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// BLAZING-FAST ZIG ALCHEMY //
const std = @import("std");

pub const Monolith = struct {
    energy: u32,

    var instance: ?*Monolith = null;

    pub fn getInstance(alloc: std.mem.Allocator) !*Monolith {
        if (instance == null) {
            const new_instance = try alloc.create(Monolith);
            new_instance.* = Monolith{ .energy = 9999 };
            instance = new_instance;
        }
        return instance.?;
    }
};

Some entities are too massive, too volatile, to exist in plurality. The Monolith Binding (Singleton) ensures that across the entire runtime dimension, only one conduit is forged. Be warned: manipulating global state in Zig requires thread-safe transmutation if your rituals invoke concurrent casting.

Runic Tags: #singleton #creational #zig #monolith