Renamed the project to Umbraco.PublishedCache.NuCache - and move non NuCache related stuff to abstractions and infrastructure.

This commit is contained in:
Bjarke Berg
2020-02-06 14:40:46 +01:00
parent 0bc843b06d
commit d147b182ee
50 changed files with 28 additions and 27 deletions

View File

@@ -0,0 +1,37 @@
using System;
using System.Threading;
namespace Umbraco.Web.PublishedCache.NuCache.Snap
{
internal class GenObj
{
public GenObj(long gen)
{
Gen = gen;
WeakGenRef = new WeakReference(null);
}
public GenRef GetGenRef()
{
// not thread-safe but always invoked from within a lock
var genRef = (GenRef)WeakGenRef.Target;
if (genRef == null)
WeakGenRef.Target = genRef = new GenRef(this);
return genRef;
}
public readonly long Gen;
public readonly WeakReference WeakGenRef;
public int Count;
public void Reference()
{
Interlocked.Increment(ref Count);
}
public void Release()
{
Interlocked.Decrement(ref Count);
}
}
}