Created
February 15, 2022 09:09
-
-
Save javiercampos/6e611e10e648c531a553c4494ecd6cb3 to your computer and use it in GitHub Desktop.
Guard
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
public class Guard | |
{ | |
private int _guardValue = 0; | |
public bool Once() => Interlocked.Exchange(ref _guardValue, 1) == 0; | |
public void Reset() => Interlocked.Exchange(ref _guardValue, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment