From 6bd2b155d2e4a40a28ab9f27807deda3c29691f0 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 29 Sep 2026 04:40:07 +0200 Subject: [PATCH] Move the Generator's lock-free-reader invariant from its godoc onto mu --- fejkdata.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fejkdata.go b/fejkdata.go index 8fa244a..d913c5f 100644 --- a/fejkdata.go +++ b/fejkdata.go @@ -28,10 +28,11 @@ var ErrNoData = errors.New("no data: WithoutShippedData needs at least one WithD // Generator generates fake data from a loaded namespace tree. Create one with [New]. // It is safe for concurrent use; a seeded sequence is reproducible only when drawn -// from one goroutine. The compiled tree is fixed after [New] bar each table's row lookup, -// which its sync.Once builds on first use, so List, NewTemplate and NewRecordTemplate -// read it without a lock; mu guards the rest, which every render takes. +// from one goroutine. type Generator struct { + // mu guards what a render touches. The tree under root is fixed after New bar each + // table's row lookup, built under its sync.Once, so List, NewTemplate and + // NewRecordTemplate read it without mu. mu sync.Mutex rand *session root folder // the categories as the node a path walks from, owned here so a walk allocates none