-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: turn GetFirstEnabledActions into GetAction
- Loading branch information
Showing
6 changed files
with
67 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
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
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,32 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
internal static class ThreadSafeRandom | ||
{ | ||
[ThreadStatic] | ||
private static Random? _local; | ||
private static readonly Random _global = new(); | ||
|
||
private static Random _instance | ||
{ | ||
get | ||
{ | ||
if (_local is null) | ||
{ | ||
int seed; | ||
lock (_global) | ||
{ | ||
seed = _global.Next(); | ||
} | ||
|
||
_local = new Random(seed); | ||
} | ||
|
||
return _local; | ||
} | ||
} | ||
|
||
public static int Next() => _instance.Next(); | ||
|
||
public static int Next(int maxValue) => _instance.Next(maxValue); | ||
} |
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