-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6325941
commit 1d616ee
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
projects/RabbitMQ.Client/FrameworkExtension/Interlocked.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Note: | ||
// The code in this file is inspired by the code in `dotnet/runtime`, in this file: | ||
// src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Interlocked.cs | ||
// | ||
// The license from that file is as follows: | ||
// | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
|
||
|
||
using System.Runtime.CompilerServices; | ||
|
||
namespace RabbitMQ.Client | ||
{ | ||
#if NETSTANDARD | ||
// TODO GH-1308 class should be called "Interlocked" to be used by other code | ||
internal static class InterlockedExtensions | ||
{ | ||
public static ulong CompareExchange(ref ulong location1, ulong value, ulong comparand) | ||
{ | ||
return (ulong)System.Threading.Interlocked.CompareExchange(ref Unsafe.As<ulong, long>(ref location1), (long)value, (long)comparand); | ||
} | ||
|
||
public static ulong Increment(ref ulong location1) | ||
{ | ||
return (ulong)System.Threading.Interlocked.Add(ref Unsafe.As<ulong, long>(ref location1), 1L); | ||
} | ||
} | ||
#endif | ||
} |