2023-03-14 08:02:43 +03:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
2023-03-16 19:09:10 +03:00
|
|
|
|
namespace DotRecast.Core
|
|
|
|
|
{
|
2023-03-16 19:48:49 +03:00
|
|
|
|
public class AtomicBoolean
|
2023-03-14 08:02:43 +03:00
|
|
|
|
{
|
2023-03-16 19:48:49 +03:00
|
|
|
|
private volatile int _location;
|
2023-03-14 08:02:43 +03:00
|
|
|
|
|
2023-03-16 19:48:49 +03:00
|
|
|
|
public bool set(bool v)
|
|
|
|
|
{
|
|
|
|
|
return 0 != Interlocked.Exchange(ref _location, v ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool get()
|
|
|
|
|
{
|
|
|
|
|
return 0 != _location;
|
|
|
|
|
}
|
2023-03-14 08:02:43 +03:00
|
|
|
|
}
|
|
|
|
|
}
|