Skip to content

Commit 1d616ee

Browse files
committed
1 parent 6325941 commit 1d616ee

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Note:
2+
// The code in this file is inspired by the code in `dotnet/runtime`, in this file:
3+
// src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Interlocked.cs
4+
//
5+
// The license from that file is as follows:
6+
//
7+
// Licensed to the .NET Foundation under one or more agreements.
8+
// The .NET Foundation licenses this file to you under the MIT license.
9+
10+
11+
12+
using System.Runtime.CompilerServices;
13+
14+
namespace RabbitMQ.Client
15+
{
16+
#if NETSTANDARD
17+
// TODO GH-1308 class should be called "Interlocked" to be used by other code
18+
internal static class InterlockedExtensions
19+
{
20+
public static ulong CompareExchange(ref ulong location1, ulong value, ulong comparand)
21+
{
22+
return (ulong)System.Threading.Interlocked.CompareExchange(ref Unsafe.As<ulong, long>(ref location1), (long)value, (long)comparand);
23+
}
24+
25+
public static ulong Increment(ref ulong location1)
26+
{
27+
return (ulong)System.Threading.Interlocked.Add(ref Unsafe.As<ulong, long>(ref location1), 1L);
28+
}
29+
}
30+
#endif
31+
}

0 commit comments

Comments
 (0)