Added RefCounted helpers

This commit is contained in:
Simon Lübeß
2021-09-21 16:29:22 +02:00
parent 4debaee7d4
commit 8e39d7988b
+23
View File
@@ -0,0 +1,23 @@
using System;
using DirectX.Common;
namespace GlitchyEngine
{
static
{
/// Releases the reference to destination, writes newValue into it and adds a reference to newValue.
public static mixin SetReference<T>(T destination, T newValue) where T: RefCounted
{
destination?.ReleaseRef();
destination = newValue;
destination?.AddRef();
}
/// Releases the reference to value and nullifies it.
public static mixin ReleaseRefAndNullify<T>(T value) where T: RefCounted
{
value?.ReleaseRef();
value = null;
}
}
}