Skip to content

v0.2.21

Choose a tag to compare

@zhuxiujia zhuxiujia released this 23 Aug 15:07
· 5 commits to main since this release

This release reworks SyncHashMap, SyncBtreeMap, SyncIndexMap, and SyncVec around a read/dirty + atomic snapshot design, matching Go's sync.Map:

  • Lock-free reads. get, iter, and Index are served from an immutable snapshot that is atomically published via an atomic pointer. Readers never block on the
    write lock.

  • O(1) updates. Every slot is a shared Arc<Entry> holding an atomic pointer to the value. Updating an existing key swaps the pointer in place — no map
    rebuild, no snapshot refresh — and readers immediately observe the new value.

  • Lazy promotion (amended). New keys and appends are written to a dirty map and published into a fresh snapshot only when needed. get / len / is_empty /
    contains_key are fully lock-free on a miss when nothing is pending.

  • Reference stability. Snapshots and retired values are kept alive until the container is dropped, so references returned by get remain valid even across
    concurrent mutations and removals.