Table of Contents

Namespace Utils.Common.Collections.Synchronized

Classes

SyncDictionary<TKey, TValue>

A dictionary whose individual operations lock on SyncRoot, so single calls are safe from several threads. Compound operations are not atomic unless the caller locks on SyncRoot; GetOrAdd(TKey, Func<TKey, TValue>), TryAdd(TKey, TValue) and TryGetAndRemove(TKey) cover the common cases. Cache is an array snapshot of the values that is rebuilt lazily after every modification.

SyncList<T>

A list whose individual operations lock on SyncRoot, so single calls are safe from several threads. Compound operations (check-then-act, enumeration) are not atomic: lock on SyncRoot around them, or read Cache, an array snapshot that is rebuilt lazily after every modification.

Interfaces

ICachedCollection<T>

A synchronized collection that also exposes an array snapshot of its items, for reading or enumerating while other threads may modify the collection.