mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Added RefCounted helpers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user