EgretDoc
Back to Home
Location:system/sync

Module

Module documentation.

modulesync
@briefConcurrency primitives
@detailsProvides wrappers for Mutex/CondVar/atomic Int64/WaitGroup/Once.
@see
  • index.html

Classes

Classes and inheritance.

classsync::Int64
@briefInt64
@noteMemory-ordering semantics of add/load/store/compare_and_swap depend on the runtime implementation.
class Int64 {
    /*
    @brief Underlying handle
classsync::Mutex
@briefMutex
@detailsMutex wrapper (provided by the runtime)
class Mutex {
    /*
    @brief Underlying handle
classsync::CondVar
@briefCondVar
@detailsCondition variable wrapper. Wait methods must be called while holding the associated Mutex.
class CondVar {
    /*
    @brief Underlying handle
classsync::WaitGroup
@briefWaitGroup
class WaitGroup {
    /*
    @brief Counter
classsync::Once
@briefOnce
@noteNon-first do calls return 0 immediately.
class Once {
    /*
    @brief State flag

Functions

Free functions and class methods.

functionsync::__mutex_new
Signatureextern func __mutex_new() -> Int;
extern func __mutex_new() -> Int;
/*
@brief Binds the low-level runtime symbol `__mutex_free`.
@briefBinds the low-level runtime symbol `__mutex_new`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@returnReturns the operation result as `Int`.
functionsync::__mutex_free
Signatureextern func __mutex_free(h: Int) -> Void;
extern func __mutex_free(h: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__mutex_lock`.
@briefBinds the low-level runtime symbol `__mutex_free`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
@returnVoid
functionsync::__mutex_lock
Signatureextern func __mutex_lock(h: Int) -> Void;
extern func __mutex_lock(h: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__mutex_unlock`.
@briefBinds the low-level runtime symbol `__mutex_lock`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
@returnVoid
functionsync::__mutex_unlock
Signatureextern func __mutex_unlock(h: Int) -> Void;
extern func __mutex_unlock(h: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__condvar_new`.
@briefBinds the low-level runtime symbol `__mutex_unlock`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
@returnVoid
functionsync::__condvar_new
Signatureextern func __condvar_new() -> Int;
extern func __condvar_new() -> Int;
/*
@brief Binds the low-level runtime symbol `__condvar_free`.
@briefBinds the low-level runtime symbol `__condvar_new`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@returnReturns the operation result as `Int`.
functionsync::__condvar_free
Signatureextern func __condvar_free(h: Int) -> Void;
extern func __condvar_free(h: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__condvar_wait`.
@briefBinds the low-level runtime symbol `__condvar_free`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
@returnVoid
functionsync::__condvar_wait
Signatureextern func __condvar_wait(cv_h: Int, mutex_h: Int) -> Void;
extern func __condvar_wait(cv_h: Int, mutex_h: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__condvar_wait_timeout_ms`.
@briefBinds the low-level runtime symbol `__condvar_wait`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • cv_hNative handle used to identify the cv handle resource.
  • mutex_hNative handle used to identify the mutex handle resource.
@returnVoid
functionsync::__condvar_wait_timeout_ms
Signatureextern func __condvar_wait_timeout_ms(cv_h: Int, mutex_h: Int, timeout_ms: Int) -> Int;
extern func __condvar_wait_timeout_ms(cv_h: Int, mutex_h: Int, timeout_ms: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__condvar_signal`.
@briefBinds the low-level runtime symbol `__condvar_wait_timeout_ms`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • cv_hNative handle used to identify the cv handle resource.
  • mutex_hNative handle used to identify the mutex handle resource.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionsync::__condvar_signal
Signatureextern func __condvar_signal(h: Int) -> Void;
extern func __condvar_signal(h: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__condvar_broadcast`.
@briefBinds the low-level runtime symbol `__condvar_signal`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
@returnVoid
functionsync::__condvar_broadcast
Signatureextern func __condvar_broadcast(h: Int) -> Void;
extern func __condvar_broadcast(h: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__atomic_i64_new`.
@briefBinds the low-level runtime symbol `__condvar_broadcast`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
@returnVoid
functionsync::__atomic_i64_new
Signatureextern func __atomic_i64_new(init: Int) -> Int;
extern func __atomic_i64_new(init: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__atomic_i64_free`.
@briefBinds the low-level runtime symbol `__atomic_i64_new`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • initInitial value used when constructing or resetting the object.
@returnReturns the operation result as `Int`.
functionsync::__atomic_i64_free
Signatureextern func __atomic_i64_free(h: Int) -> Void;
extern func __atomic_i64_free(h: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__atomic_i64_add`.
@briefBinds the low-level runtime symbol `__atomic_i64_free`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
@returnVoid
functionsync::__atomic_i64_add
Signatureextern func __atomic_i64_add(h: Int, delta: Int) -> Int;
extern func __atomic_i64_add(h: Int, delta: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__atomic_i64_load`.
@briefBinds the low-level runtime symbol `__atomic_i64_add`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
  • deltaSigned amount added to or subtracted from the current numeric value.
@returnReturns the operation result as `Int`.
functionsync::__atomic_i64_load
Signatureextern func __atomic_i64_load(h: Int) -> Int;
extern func __atomic_i64_load(h: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__atomic_i64_store`.
@briefBinds the low-level runtime symbol `__atomic_i64_load`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
@returnReturns the operation result as `Int`.
functionsync::__atomic_i64_store
Signatureextern func __atomic_i64_store(h: Int, val: Int) -> Void;
extern func __atomic_i64_store(h: Int, val: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__atomic_i64_cas`.
@briefBinds the low-level runtime symbol `__atomic_i64_store`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
  • valValue supplied by the caller for storage, comparison, encoding, or transmission.
@returnVoid
functionsync::__atomic_i64_cas
Signatureextern func __atomic_i64_cas(h: Int, expected: Int, desired: Int) -> Int;
extern func __atomic_i64_cas(h: Int, expected: Int, desired: Int) -> Int;

/*
@briefBinds the low-level runtime symbol `__atomic_i64_cas`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
  • expectedExpected value used for validation, comparison, or conditional update.
  • desiredDesired target value requested by the caller.
@returnReturns the operation result as `Int`.
functionsync::atomic_i64_new
Signaturefunc atomic_i64_new(init: Int) -> Int
func atomic_i64_new(init: Int) -> Int {
    return __atomic_i64_new(init);
}
@briefProvides the system library operation `atomic_i64_new`.
@detailsExecutes the `atomic_i64_new` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • initInitial value used when constructing or resetting the object.
@returnReturns the operation result as `Int`.
functionsync::atomic_i64_free
Signaturefunc atomic_i64_free(h: Int) -> Void
func atomic_i64_free(h: Int) -> Void {
    _ = __atomic_i64_free(h);
    return;
@briefProvides the system library operation `atomic_i64_free`.
@detailsExecutes the `atomic_i64_free` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hUnderlying runtime handle.
@returnVoid
functionsync::atomic_i64_load
Signaturefunc atomic_i64_load(h: Int) -> Int
func atomic_i64_load(h: Int) -> Int {
    return __atomic_i64_load(h);
}
@briefProvides the system library operation `atomic_i64_load`.
@detailsExecutes the `atomic_i64_load` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hUnderlying runtime handle.
@returnReturns the operation result as `Int`.
functionsync::atomic_i64_store
Signaturefunc atomic_i64_store(h: Int, val: Int) -> Void
func atomic_i64_store(h: Int, val: Int) -> Void {
    _ = __atomic_i64_store(h, val);
    return;
@briefProvides the system library operation `atomic_i64_store`.
@detailsExecutes the `atomic_i64_store` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hUnderlying runtime handle.
  • valValue supplied by the caller for storage, comparison, encoding, or transmission.
@returnVoid
functionsync::Int64.init
Signaturefunc init(self: sync.Int64, init: Int) -> Void
    func init(self: sync.Int64, init: Int) -> Void {
        self.h = __atomic_i64_new(init);
    }
@briefCreate an atomic variable
@param
  • selfInt64 instance
  • initInitial value
@returnVoid
functionsync::Int64.free
Signaturefunc free(self: sync.Int64) -> Void
    func free(self: sync.Int64) -> Void {
        if self.h == 0 {
            return;
@briefFree the atomic variable
@detailsFrees the underlying handle and sets h to 0.
@param
  • selfInt64 instance
@returnVoid
functionsync::Int64.dispose
Signaturefunc dispose(self: sync.Int64) -> Void
    func dispose(self: sync.Int64) -> Void {
        _ = self.free();
    }
@briefExplicitly releases resources owned by `Int64`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionsync::Int64.deinit
Signaturefunc deinit(self: sync.Int64) -> Void
    func deinit(self: sync.Int64) -> Void {
        if self.h != 0 {
            _ = self.free();
@briefDeinitialize the atomic variable
@detailsAutomatically releases the underlying runtime handle when the object is collected.
@param
  • selfInt64 instance
@returnVoid
functionsync::Int64.add
Signaturefunc add(self: sync.Int64, delta: Int) -> Int
    func add(self: sync.Int64, delta: Int) -> Int {
        return __atomic_i64_add(self.h, delta);
    }
@briefAtomic add
@detailsAdds delta to the atomic value and returns the result (return semantics depend on the runtime, usually the new value).
@param
  • selfInt64 instance
  • deltaDelta (may be negative)
@returnReturn value (usually the new value)
functionsync::Int64.load
Signaturefunc load(self: sync.Int64) -> Int
    func load(self: sync.Int64) -> Int {
        return __atomic_i64_load(self.h);
    }
@briefAtomic load
@param
  • selfInt64 instance
@returnCurrent value
functionsync::Int64.store
Signaturefunc store(self: sync.Int64, v: Int) -> Void
    func store(self: sync.Int64, v: Int) -> Void {
        _ = __atomic_i64_store(self.h, v);
    }
@briefAtomic store
@param
  • selfInt64 instance
  • vNew value to store
@returnVoid
functionsync::Int64.compare_and_swap
Signaturefunc compare_and_swap(self: sync.Int64, expected: Int, desired: Int) -> Bool
    func compare_and_swap(self: sync.Int64, expected: Int, desired: Int) -> Bool {
        return __atomic_i64_cas(self.h, expected, desired) == 1;
    }
@briefAtomic compare-and-swap (CAS)
@param
  • selfInt64 instance
  • expectedExpected value
  • desiredDesired value
@returnWhether the swap succeeded
functionsync::Mutex.init
Signaturefunc init(self: sync.Mutex) -> Void
    func init(self: sync.Mutex) -> Void {
        self.h = __mutex_new();
    }
@briefCreate a mutex
@param
  • selfMutex instance
@returnVoid
functionsync::Mutex.free
Signaturefunc free(self: sync.Mutex) -> Void
    func free(self: sync.Mutex) -> Void {
        if self.h == 0 {
            return;
@briefFree the mutex
@detailsFrees the underlying handle and sets h to 0.
@param
  • selfMutex instance
@returnVoid
functionsync::Mutex.dispose
Signaturefunc dispose(self: sync.Mutex) -> Void
    func dispose(self: sync.Mutex) -> Void {
        _ = self.free();
    }
@briefExplicitly releases resources owned by `Mutex`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionsync::Mutex.deinit
Signaturefunc deinit(self: sync.Mutex) -> Void
    func deinit(self: sync.Mutex) -> Void {
        if self.h != 0 {
            _ = self.free();
@briefDeinitialize the mutex
@detailsAutomatically releases the underlying runtime mutex handle when the object is collected.
@param
  • selfMutex instance
@returnVoid
functionsync::Mutex.lock
Signaturefunc lock(self: sync.Mutex) -> Void
    func lock(self: sync.Mutex) -> Void {
        _ = __mutex_lock(self.h);
    }
@briefLock
@param
  • selfMutex instance
@returnVoid
functionsync::Mutex.unlock
Signaturefunc unlock(self: sync.Mutex) -> Void
    func unlock(self: sync.Mutex) -> Void {
        _ = __mutex_unlock(self.h);
    }
@briefUnlock
@param
  • selfMutex instance
@returnVoid
functionsync::CondVar.init
Signaturefunc init(self: sync.CondVar) -> Void
    func init(self: sync.CondVar) -> Void {
        self.h = __condvar_new();
    }
@briefCreate a condition variable
@param
  • selfCondVar instance
@returnVoid
functionsync::CondVar.free
Signaturefunc free(self: sync.CondVar) -> Void
    func free(self: sync.CondVar) -> Void {
        if self.h == 0 {
            return;
@briefFree the condition variable
@detailsFrees the underlying handle and sets h to 0.
@param
  • selfCondVar instance
@returnVoid
functionsync::CondVar.dispose
Signaturefunc dispose(self: sync.CondVar) -> Void
    func dispose(self: sync.CondVar) -> Void {
        _ = self.free();
    }
@briefExplicitly releases resources owned by `CondVar`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionsync::CondVar.deinit
Signaturefunc deinit(self: sync.CondVar) -> Void
    func deinit(self: sync.CondVar) -> Void {
        if self.h != 0 {
            _ = self.free();
@briefDeinitialize the condition variable
@detailsAutomatically releases the underlying runtime condition variable handle when the object is collected.
@param
  • selfCondVar instance
@returnVoid
functionsync::CondVar.wait
Signaturefunc wait(self: sync.CondVar, mu: sync.Mutex) -> Void
    func wait(self: sync.CondVar, mu: sync.Mutex) -> Void {
        _ = __condvar_wait(self.h, mu.h);
    }
@briefWait until signaled
@detailsAtomically releases mu while waiting and re-acquires it before returning.
@param
  • selfCondVar instance
  • muMutex held by the caller
@returnVoid
functionsync::CondVar.wait_timeout
Signaturefunc wait_timeout(self: sync.CondVar, mu: sync.Mutex, timeout_ms: Int) -> Bool
    func wait_timeout(self: sync.CondVar, mu: sync.Mutex, timeout_ms: Int) -> Bool {
        return __condvar_wait_timeout_ms(self.h, mu.h, timeout_ms) == 1;
    }
@briefWait with timeout
@detailsReturns true if signaled before timeout, false on timeout.
@param
  • selfCondVar instance
  • muMutex held by the caller
  • timeout_msTimeout in milliseconds
@returnWhether the wait was signaled
functionsync::CondVar.signal
Signaturefunc signal(self: sync.CondVar) -> Void
    func signal(self: sync.CondVar) -> Void {
        _ = __condvar_signal(self.h);
    }
@briefWake one waiter
@param
  • selfCondVar instance
@returnVoid
functionsync::CondVar.broadcast
Signaturefunc broadcast(self: sync.CondVar) -> Void
    func broadcast(self: sync.CondVar) -> Void {
        _ = __condvar_broadcast(self.h);
    }
@briefWake all waiters
@param
  • selfCondVar instance
@returnVoid
functionsync::WaitGroup.init
Signaturefunc init(self: sync.WaitGroup) -> Void
    func init(self: sync.WaitGroup) -> Void {
        self.mu = new sync.Mutex();
        self.cv = new sync.CondVar();
@briefInitialize a WaitGroup
@detailsInitializes the counter to 0.
@param
  • selfWaitGroup instance
@returnVoid
functionsync::WaitGroup.add
Signaturefunc add(self: sync.WaitGroup, delta: Int) -> Void
    func add(self: sync.WaitGroup, delta: Int) -> Void {
        _ = self.mu.lock();
        self.c += delta;
@briefAdd or subtract the counter
@param
  • selfWaitGroup instance
  • deltaDelta (typically positive to add tasks, negative to mark tasks done)
@returnVoid
functionsync::WaitGroup.done
Signaturefunc done(self: sync.WaitGroup) -> Void
    func done(self: sync.WaitGroup) -> Void {
        _ = self.add(-1);
    }
@briefMark one task as done
@detailsEquivalent to add(-1).
@param
  • selfWaitGroup instance
@returnVoid
functionsync::WaitGroup.wait
Signaturefunc wait(self: sync.WaitGroup) -> Void
    func wait(self: sync.WaitGroup) -> Void {
        _ = self.mu.lock();
        loop (; self.c > 0; ) {
@briefWait for all tasks to complete
@param
  • selfWaitGroup instance
@returnVoid
functionsync::WaitGroup.deinit
Signaturefunc deinit(self: sync.WaitGroup) -> Void
    func deinit(self: sync.WaitGroup) -> Void {
        _ = self.cv.free();
        _ = self.mu.free();
@briefDeinitialize the WaitGroup
@detailsReleases the internal condition variable and mutex handles.
@param
  • selfWaitGroup instance
@returnVoid
functionsync::WaitGroup.dispose
Signaturefunc dispose(self: sync.WaitGroup) -> Void
    func dispose(self: sync.WaitGroup) -> Void {
        _ = self.cv.dispose();
        _ = self.mu.dispose();
@briefExplicitly releases resources owned by `WaitGroup`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionsync::Once.init
Signaturefunc init(self: sync.Once) -> Void
    func init(self: sync.Once) -> Void {
        self.done = new sync.Int64(0);
    }
@briefInitialize Once
@detailsSets done to 0.
@param
  • selfOnce instance
@returnVoid
functionsync::Once.do
Signaturefunc do(self: sync.Once, f: (Int) -> Int, arg: Int) -> Int
    func do(self: sync.Once, f: (Int) -> Int, arg: Int) -> Int {
        if self.done.compare_and_swap(0, 1) {
            return f(arg);
@briefExecute once
@param
  • selfOnce instance
  • fFunction to execute (signature: (Int)->Int)
  • argArgument passed to f
@returnReturn value of f(arg).
functionsync::Once.deinit
Signaturefunc deinit(self: sync.Once) -> Void
    func deinit(self: sync.Once) -> Void {
        _ = self.done.free();
    }
@briefDeinitialize Once
@detailsReleases the internal atomic state handle.
@param
  • selfOnce instance
@returnVoid
functionsync::Once.dispose
Signaturefunc dispose(self: sync.Once) -> Void
    func dispose(self: sync.Once) -> Void {
        _ = self.done.dispose();
    }
@briefExplicitly releases resources owned by `Once`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid

Variables

Class fields (var).

varsync::Int64.h
TypeInt
@briefUnderlying handle
@detailsHandle to the runtime atomic object (created by __atomic_i64_new)
    var h: Int;

    /*
varsync::Mutex.h
TypeInt
@briefUnderlying handle
@detailsHandle to the runtime mutex
    var h: Int;

    /*
varsync::CondVar.h
TypeInt
@briefUnderlying handle
@detailsHandle to the runtime condition variable
    var h: Int;

    /*
varsync::WaitGroup.mu
Typesync.Mutex
@briefCounter
@detailsNumber of unfinished tasks, protected by mu
    var mu: sync.Mutex;
    /*
    @brief `cv` field.
varsync::WaitGroup.cv
Typesync.CondVar
@brief`cv` field.
@detailsHolds the `cv` value for each `WaitGroup` instance. The field type is `sync.CondVar`, and constructors and methods keep it synchronized with the object's runtime state.
    var cv: sync.CondVar;
    /*
    @brief `c` field.
varsync::WaitGroup.c
TypeInt
@brief`c` field.
@detailsHolds the `c` value for each `WaitGroup` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
    var cv: sync.CondVar;
    /*
    @brief `c` field.
varsync::Once.done
Typesync.Int64
@briefState flag
@detailsdone=0 means not executed, done=1 means executed
    var done: sync.Int64;

    /*