Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion BitFaster.Caching/Counters/Striped64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ namespace BitFaster.Caching.Counters
public abstract class Striped64
{
// Number of CPUS, to place bound on table size
#if NETCOREAPP2_1_OR_GREATER
private static readonly int MaxBuckets = BitOps.CeilingPowerOfTwo(Environment.ProcessorCount);
#else
private static readonly int MaxBuckets = Environment.ProcessorCount * 4;

#endif
/// <summary>
/// The base value used mainly when there is no contention, but also as a fallback
/// during table initialization races. Updated via CAS.
Expand Down Expand Up @@ -135,7 +138,11 @@ private void VolatileWriteNotBusy()
protected static int GetProbe()
{
// Note: this results in higher throughput than introducing a random.
#if NETCOREAPP2_1_OR_GREATER
return Thread.GetCurrentProcessorId();
#else
return Environment.CurrentManagedThreadId;
#endif
}

/**
Expand Down
Loading