namespace Swan.Threading
{
///
/// Fast, atomic boolean combining interlocked to write value and volatile to read values.
///
public sealed class AtomicBoolean : AtomicTypeBase
{
///
/// Initializes a new instance of the class.
///
/// if set to true [initial value].
public AtomicBoolean(bool initialValue = default)
: base(initialValue ? 1 : 0)
{
// placeholder
}
///
protected override bool FromLong(long backingValue) => backingValue != 0;
///
protected override long ToLong(bool value) => value ? 1 : 0;
}
}