2023-03-14 08:02:43 +03:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
2023-03-16 19:09:10 +03:00
|
|
|
|
namespace DotRecast.Core
|
|
|
|
|
{
|
|
|
|
|
|
2023-03-14 08:02:43 +03:00
|
|
|
|
|
|
|
|
|
public class AtomicFloat
|
|
|
|
|
{
|
|
|
|
|
private volatile float _location;
|
|
|
|
|
|
|
|
|
|
public AtomicFloat(float location)
|
|
|
|
|
{
|
|
|
|
|
_location = location;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Get()
|
|
|
|
|
{
|
|
|
|
|
return _location;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Exchange(float exchange)
|
|
|
|
|
{
|
|
|
|
|
return Interlocked.Exchange(ref _location, exchange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float CompareExchange(float value, float comparand)
|
|
|
|
|
{
|
|
|
|
|
return Interlocked.CompareExchange(ref _location, value, comparand);
|
|
|
|
|
}
|
2023-03-16 19:09:10 +03:00
|
|
|
|
}
|
2023-03-14 08:02:43 +03:00
|
|
|
|
}
|