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

Commit 28e3939

Browse files
ViktorHoferdanmoseley
authored andcommitted
Volatile and readonly in Reference helper classes in Regex
1 parent febb0de commit 28e3939

File tree

1 file changed

+3
-3
lines changed
  • src/System.Text.RegularExpressions/src/System/Text/RegularExpressions

1 file changed

+3
-3
lines changed

src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Reference.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal sealed class ExclusiveReference
1313
{
1414
private RegexRunner _ref;
1515
private object _obj;
16-
private int _locked;
16+
private volatile int _locked;
1717

1818
/// <summary>
1919
/// Return an object and grab an exclusive lock.
@@ -91,8 +91,8 @@ public void Release(object obj)
9191
/// </summary>
9292
internal sealed class SharedReference
9393
{
94-
private WeakReference _ref = new WeakReference(null);
95-
private int _locked;
94+
private readonly WeakReference _ref = new WeakReference(null);
95+
private volatile int _locked;
9696

9797
/// <summary>
9898
/// Return an object from a weakref, protected by a lock.

0 commit comments

Comments
 (0)