StefanSchade / TaleForge

Text Adventure Logic Engine - A plattform to create immersive games without coding
0 stars 0 forks source link

Concurrency and State Management #34

Open StefanSchade opened 5 months ago

StefanSchade commented 5 months ago

Mutex Overhead:

Using Mutex<HashMap<...>> for state management is straightforward but might become a bottleneck under high load due to lock contention. If performance under concurrency is critical, consider using concurrent collections like those in the dashmap crate.

Immutable Data Structures:

For read-heavy workloads, immutable data structures can reduce lock contention. Libraries like im provide such data structures.

StefanSchade commented 5 months ago

Your in-memory repositories use Mutex<HashMap<>> for thread safety. Consider using RwLock instead if reads are more frequent than writes, as it allows multiple readers simultaneously.