Egodystonic.Atomics
1.0.0-alpha1
dotnet add package Egodystonic.Atomics --version 1.0.0-alpha1
NuGet\Install-Package Egodystonic.Atomics -Version 1.0.0-alpha1
<PackageReference Include="Egodystonic.Atomics" Version="1.0.0-alpha1" />
paket add Egodystonic.Atomics --version 1.0.0-alpha1
#r "nuget: Egodystonic.Atomics, 1.0.0-alpha1"
// Install Egodystonic.Atomics as a Cake Addin #addin nuget:?package=Egodystonic.Atomics&version=1.0.0-alpha1&prerelease // Install Egodystonic.Atomics as a Cake Tool #tool nuget:?package=Egodystonic.Atomics&version=1.0.0-alpha1&prerelease
Egodystonic.Atomics
Atomics is a C#/.NET Standard 2.0 library aimed at providing thread-safe wrappers for mutable shared state variables.
Please note: This library is currently in alpha. There is no inline documentation yet and the API is liable to minor changes.
Library Features
- Provides built-in mechanisms for operating on mutable variables in discrete, atomic operations; including 'basics' like compare-and-swap/increment etc. but also more complex or arbitrary routines, making it easier to reason about potential concurrent accesses and eliminate accidental race conditions.
- Helps ensure that all accesses to wrapped variables are done in a threadsafe manner. Unlike with other synchronization primitives, mutable variables wrapped in an
Atomic<T>
wrapper are much harder to accidentally alter in an unsafe way. - Almost all operations are "lock-free", resulting in high-scalability for almost any contention level and any number of threads; with a suite of benchmarks used to measure performance and guide implementation.
- A full suite of unit tests with a custom-built harness for testing the entire library with multiple concurrent threads.
- Support for custom equality (e.g. compare-and-swap with two
IEquatable<>
objects will use theirEquals()
function for comparison). - Library is targeted to .NET Standard 2.0 which is supported by most modern .NET platforms.
- MIT licensed.
Library Advantages
Although the best design for threadsafe code is to have no mutable state at all, sometimes it is a necessity for performance or reasons of complexity.
As growth in single-core computing power is slowing, scaling via parallelism with higher CPU core counts is becoming an increasingly important way to increase application responsiveness. The latest generation of desktop CPUs have more threads than ever before, with the flagship specs currently being Intel's i9 9900k (16 threads) and AMD's Threadripper 2950X (32 threads).
Currently the .NET FCL/BCL offers a great suite of tools for writing parellized/concurrent code with async/await
, concurrent & immutable collections, Task
s and the TPL, and more fundamental constructs like locks, semaphores, reader-writer locks, and more.
However, one potentially missing element is the provision for threadsafe single variables, often used as part of a larger concurrent algorithm or data structure. Many other languages provide a similar library, including C++, Java, Rust, and Go.
Documentation
For more documentation, please visit the github page at https://github.com/Egodystonic/Atomics
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Runtime.CompilerServices.Unsafe (>= 4.5.2)
- System.Threading.Tasks.Extensions (>= 4.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0-alpha1 | 655 | 2/14/2019 |