2023-03-14 08:02:43 +03:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
2023-03-16 19:09:10 +03:00
|
|
|
|
namespace DotRecast.Core
|
|
|
|
|
{
|
2023-05-06 05:44:57 +03:00
|
|
|
|
public class RcAtomicBoolean
|
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-05-05 02:44:48 +03:00
|
|
|
|
public bool Set(bool v)
|
2023-03-16 19:48:49 +03:00
|
|
|
|
{
|
|
|
|
|
return 0 != Interlocked.Exchange(ref _location, v ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 02:44:48 +03:00
|
|
|
|
public bool Get()
|
2023-03-16 19:48:49 +03:00
|
|
|
|
{
|
|
|
|
|
return 0 != _location;
|
|
|
|
|
}
|
2023-03-14 08:02:43 +03:00
|
|
|
|
}
|
|
|
|
|
}
|