https://github.com/dcastro/dequenet
https://github.com/dcastro/dequenet
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/dcastro/dequenet
- Owner: dcastro
- License: apache-2.0
- Created: 2013-12-22T22:00:47.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2016-11-01T00:05:57.000Z (over 9 years ago)
- Last Synced: 2025-03-16T14:19:48.303Z (over 1 year ago)
- Language: C#
- Size: 582 KB
- Stars: 29
- Watchers: 3
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DequeNET
DequeNET (pronounced Deck Net) provides a concurrent lock-free deque C# implementation.
A deque, or double-ended queue, is a data structure that allows insertion and removal of items on both ends.
As such, `ConcurrentDeque` supports 4 main operations (PushRight, PopRight, PushLeft and PopLeft) plus 2 others (PeekRight and PeekLeft).
The library also offers a simpler `Deque` (not thread safe), implemented as a ring buffer.
This implementation allows all 6 operations to be executed in constant time O(1).
### The Algorithm
The implementation is based on the algorithm proposed by Maged M. Michael [1].
The algorithm uses the atomic primitive CAS (compare-and-swap) to achieve lock-freedom.
Because of this property, the algorithm guarantees system-wide progress (i.e., an operation will always complete within a finite number of steps) and is immune to deadlocks, unlike traditional mutual exclusion techniques.
Without contention, all four main operations run in constant time O(1).
Under contention by P processes, the operations' total work is O(P).
PeekRight and PeekLeft run in constant time regardless of contention.
[1] Michael, Maged, 2003, CAS-Based Lock-Free Algorithm for Shared Deques, *Euro-Par 2003 Parallel Processing*, v. 2790, p. 651-660, http://www.research.ibm.com/people/m/michael/europar-2003.pdf (Decembre 22, 2013).
### NuGet
To install DequeNET, run the following command in the Package Manager Console
```
PM> Install-Package DequeNET
```