2019-12-04 17:10:06 +01:00
|
|
|
|
using System;
|
|
|
|
|
using Unosquare.Swan.Abstractions;
|
|
|
|
|
|
|
|
|
|
namespace Unosquare.Swan {
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents an atomically readable or writable integer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class AtomicInteger : AtomicTypeBase<Int32> {
|
2019-02-17 14:08:57 +01:00
|
|
|
|
/// <summary>
|
2019-12-04 17:10:06 +01:00
|
|
|
|
/// Initializes a new instance of the <see cref="AtomicInteger"/> class.
|
2019-02-17 14:08:57 +01:00
|
|
|
|
/// </summary>
|
2019-12-04 17:10:06 +01:00
|
|
|
|
/// <param name="initialValue">if set to <c>true</c> [initial value].</param>
|
|
|
|
|
public AtomicInteger(Int32 initialValue = default)
|
|
|
|
|
: base(Convert.ToInt64(initialValue)) {
|
|
|
|
|
// placeholder
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
protected override Int32 FromLong(Int64 backingValue) =>
|
|
|
|
|
Convert.ToInt32(backingValue);
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
protected override Int64 ToLong(Int32 value) =>
|
|
|
|
|
Convert.ToInt64(value);
|
|
|
|
|
}
|
2019-02-17 14:08:57 +01:00
|
|
|
|
}
|