blob: 746593b46d4120357c198b4d700bcb1728fabdce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
using System.Threading;
namespace System.Web.Mvc.Async
{
// used to synchronize access to a single-use consumable resource
internal sealed class SingleEntryGate
{
private const int NotEntered = 0;
private const int Entered = 1;
private int _status;
// returns true if this is the first call to TryEnter(), false otherwise
public bool TryEnter()
{
int oldStatus = Interlocked.Exchange(ref _status, Entered);
return (oldStatus == NotEntered);
}
}
}
|