InterlockedUtils 1.0.1

dotnet add package InterlockedUtils --version 1.0.1                
NuGet\Install-Package InterlockedUtils -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="InterlockedUtils" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add InterlockedUtils --version 1.0.1                
#r "nuget: InterlockedUtils, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install InterlockedUtils as a Cake Addin
#addin nuget:?package=InterlockedUtils&version=1.0.1

// Install InterlockedUtils as a Cake Tool
#tool nuget:?package=InterlockedUtils&version=1.0.1                

InterlockedUtils

Provides utilities functions that can be used in addition to the built-in Interlocked class.

Usage

Add the following to use this library:

using AG;

All methods are static and can be called as follow:

var value = 15;
InterlockedUtils.Max(ref value, 12); // Returns 15
InterlockedUtils.Min(ref value, 8); // Modifies value and returns 8 atomically

All functionality makes heavy used of the built-in Interlocked class.

Methods

  • Add Add methods for all supported types (int, uint, long, ulong, nint, nuint, float, double) Note: The built-in Interlocked class only got Add for int, uint, long and ulong. You may want to use these instead unless you're doing it for the additional types implemented here.

  • Substract Substract methods for all supported types (int, uint, long, ulong, nint, nuint, float, double)

  • Multiply Multiply methods for all supported types (int, uint, long, ulong, nint, nuint, float, double)

  • Divide Divide methods for all supported types (int, uint, long, ulong, nint, nuint, float, double)

  • Modulo Modulo methods for all supported types (int, uint, long, ulong, nint, nuint, float, double)

  • Min Min methods for all supported types (int, uint, long, ulong, nint, nuint, float, double)

  • Max Max methods for all supported types (int, uint, long, ulong, nint, nuint, float, double)

  • ShiftLeft Max methods for all supported types (int, uint, long, ulong, nint, nuint, float, double)

  • ShiftRight Max methods for all supported types (int, uint, long, ulong, nint, nuint, float, double)

  • Increment Increment methods for all supported types (int, uint, long, ulong, nint, nuint, float, double) Note: The built-in Interlocked class only got Add for int, uint, long and ulong. You may want to use these instead unless you're doing it for the additional types implemented here.

  • Decrement Decrement methods for all supported types (int, uint, long, ulong, nint, nuint, float, double) Note: The built-in Interlocked class only got Add for int, uint, long and ulong. You may want to use these instead unless you're doing it for the additional types implemented here.

  • Update Update methods for all supported types (int, uint, long, ulong, nint, nuint, float, double, object, T) Update allows you to perform an arbitriary operation on a value. The operation may run multiple times until succeeded

Disclaimer

This class is not meant as a replacement for the built-in Interlocked class, but rather provide additional functionality based on it. All functionality makes heavy use of Interlocked.CompareExchange

License

MIT

Credits

Azure Gem

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

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.1 1,074 6/16/2023
1.0.0 132 6/16/2023