mirror of
https://github.com/openziti/ziti.git
synced 2026-10-26 13:39:58 +00:00
7d2685545e
A set guarded by a single RWMutex, for sets small enough or written rarely enough that one lock is not a bottleneck. The alternatives both cost more in that case: a sharded map allocates a map and a mutex per shard for every set that exists, and a copy-on-write set copies every entry per write. - adds Add, Remove, Contains, and Values, with Values returning a snapshot the caller owns - adds RemoveIf, which removes only if the value is present and a predicate agrees. The predicate runs under the write lock, so a decision that depends on state outside the set cannot be invalidated between the check and the removal