1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-20 00:50:25 +02:00

Moving corlib files out of "System" directory into root

This commit is contained in:
Brian Fiete 2019-09-19 05:46:35 -07:00
parent 4cd58262e4
commit 7dbfd15292
179 changed files with 3 additions and 0 deletions

View file

@ -0,0 +1,57 @@
using System.Threading;
using System.Diagnostics;
namespace System
{
interface IRefCounted
{
void AddRef();
void ReleaseRef();
}
class RefCounted : IRefCounted
{
protected int32 mRefCount = 1;
public ~this()
{
Debug.Assert(mRefCount == 0);
}
public int RefCount
{
get
{
return mRefCount;
}
}
public void DeleteUnchecked()
{
mRefCount = 0;
delete this;
}
public void AddRef()
{
Interlocked.Increment(ref mRefCount);
}
public void ReleaseRef()
{
int refCount = Interlocked.Decrement(ref mRefCount);
Debug.Assert(refCount >= 0);
if (refCount == 0)
{
delete this;
}
}
public int ReleaseRefNoDelete()
{
int refCount = Interlocked.Decrement(ref mRefCount);
Debug.Assert(refCount >= 0);
return refCount;
}
}
}