#sync-arena #arena #sync

sync-arena

A simple, thread-safe arena allocator

2 releases

0.1.6 Mar 26, 2025
0.1.5 Mar 25, 2025

#271 in Concurrency

Download history 185/week @ 2025-03-23 24/week @ 2025-03-30 3/week @ 2025-04-06

212 downloads per month

MIT/Apache

46KB
977 lines

The arena, a fast, thread-safe but limited type of allocator.

Arenas are a type of allocator that destroy the objects within, all at once, once the arena itself is destroyed. They do not support deallocation of individual objects while the arena itself is still alive. The benefit of an arena is very fast allocation; just a pointer bump.

This crate implements several kinds of arena.

Features

  • std-reentrant-lock: Use unstable std::sync::ReentrantLock. Requires nightly Rust.
  • lock_api: Use lock_api crate for reentrant mutex. Requires lock_api crate.
  • remutex: Use remutex crate for reentrant mutex. Requires remutex crate.

Synchronized Arena

This is a simple implementation of a synchronized arena, which is a data structure that allows multiple threads to concurrently insert elements. The arena is implemented as a linked list of blocks, where each block contains a fixed number of elements. The arena is synchronized using a single reentrant mutex.

Dependencies

~120KB