Module sync/once
sync/once
One-time initialization primitive.
Example
{ Once } :: import "std/sync/once";
init := Once.new();
// Only the first call executes the function
init.call(() => {
println("initialized!");
});
init.call(() => {
println("this will NOT run");
});
Types
Once
atomic object
Once
Execute a function exactly once, thread-safely. Uses atomic reference counting for safe cross-thread sharing.
Fields
| Name | Type | Description |
|---|---|---|
_done | atomic_bool | |
_mutex | <struct:struct_yo_id_69243> |