From 82adbb03a4912010d55935170159a2c172e392fefb512939d5f3c3c19c8935ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Bj=C3=B6rnstam?= Date: Fri, 9 Oct 2026 08:25:26 +0200 Subject: [PATCH] (std atomic) has a reference page, and Part III a section on it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [ECA](https://eca.dev) Co-Authored-By: eca-agent --- _03.Standard-library.sz | 5 +++++ modules/std/atomic.sz | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 modules/std/atomic.sz diff --git a/_03.Standard-library.sz b/_03.Standard-library.sz index 1fc3bdd..1af05eb 100644 --- a/_03.Standard-library.sz +++ b/_03.Standard-library.sz @@ -39,6 +39,11 @@ For more details, see @link["modules/std/run.html"]{@code{(std run)}}. The random module provides a ChaCha20 generator, seeded with 256 bits from the OS CSPRNG, with one generator per thread. The default path locks nothing and shares nothing, making it safe and fast on a bjoroutine. The ambient source has no state to race on, so drawing from multiple threads is efficient. You can generate random integers and more. For more details, see @link["modules/std/random.html"]{@code{(std random)}}. +@subsection{std/atomic} + +An atomic is a cell that threads can read and write without a lock. @code{(make-atomic v)} makes one of any type, and @code{atomic-ref}, @code{atomic-set!}, @code{atomic-swap!}, @code{atomic-compare-and-swap!} and @code{atomic-update!} work on it. For @code{int}, @code{uint}, @code{long} and @code{ulong} there are also @code{atomic-increment!}, @code{atomic-decrement!}, @code{atomic-add!} and @code{atomic-sub!}, which compile to direct calls to @code{System.Threading.Interlocked} and wrap on overflow. Swap and compare-and-swap return the value from before the call; the other operations that change the atomic return the new value. The width of a counter comes from type inference, so write @code{(make-atomic 0L)} for a long counter: @code{(make-atomic 0)} is an int. +For more details, see @link["modules/std/atomic.html"]{@code{(std atomic)}}. + @subsection{std/datetime} This module provides types and functions for handling time. The clock is an argument (with a default that a program can rebind), and the types refuse operations that mean nothing, such as adding a calendar day to an instant. The module separates @code{Date} (a calendar date without a timezone), @code{Time} (a time of day without a timezone), and @code{DateTime} (a date and time without a timezone), as well as handling timezones. diff --git a/modules/std/atomic.sz b/modules/std/atomic.sz new file mode 100644 index 0000000..d22b0b3 --- /dev/null +++ b/modules/std/atomic.sz @@ -0,0 +1,3 @@ +(meta (title "(std atomic)")) + +@generate-docs[#:module "std atomic"]