Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 59268ec

Browse files
jkotasstephentoub
authored andcommitted
Add Thread.GetCurrentProcessorId() API (dotnet/coreclr#16650)
Contributes to https://github.com/dotnet/corefx/issues/16767 Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent d08838a commit 59268ec

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Common/src/CoreLib/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using System.Runtime.CompilerServices;
77
using System.Threading;
88

9+
using Internal.Runtime.Augments;
10+
911
namespace System.Buffers
1012
{
1113
/// <summary>
@@ -228,7 +230,7 @@ public void TryPush(T[] array)
228230
// Try to push on to the associated stack first. If that fails,
229231
// round-robin through the other stacks.
230232
LockedStack[] stacks = _perCoreStacks;
231-
int index = Environment.CurrentExecutionId % stacks.Length;
233+
int index = RuntimeThread.GetCurrentProcessorId() % stacks.Length;
232234
for (int i = 0; i < stacks.Length; i++)
233235
{
234236
if (stacks[index].TryPush(array)) return;
@@ -244,7 +246,7 @@ public T[] TryPop()
244246
// round-robin through the other stacks.
245247
T[] arr;
246248
LockedStack[] stacks = _perCoreStacks;
247-
int index = Environment.CurrentExecutionId % stacks.Length;
249+
int index = RuntimeThread.GetCurrentProcessorId() % stacks.Length;
248250
for (int i = 0; i < stacks.Length; i++)
249251
{
250252
if ((arr = stacks[index].TryPop()) != null) return arr;

0 commit comments

Comments
 (0)