mirror of
https://github.com/snltty/linker.git
synced 2025-10-14 21:25:51 +08:00
25 lines
530 B
C#
25 lines
530 B
C#
|
|
using System.Threading;
|
|
|
|
namespace linker.libs
|
|
{
|
|
public sealed class VersionManager
|
|
{
|
|
private ulong version = 0;
|
|
|
|
public bool Eq(ulong outsideVersion, out ulong insideVersion)
|
|
{
|
|
insideVersion = version;
|
|
return outsideVersion == version;
|
|
}
|
|
|
|
public void Add()
|
|
{
|
|
if(Interlocked.Increment(ref version) > ulong.MaxValue - ushort.MaxValue)
|
|
{
|
|
Interlocked.Exchange(ref version, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|