-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1310 from rabbitmq/rabbitmq-dotnet-client-1308-2
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
// 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 | ||
} |