Files
GhostEngine/src/Test/Ghost.UnitTest/MockingEnvironment/MockingFence.cs
Misaki d2bf2f12a2 Refactor asset streaming, error handling, and unit tests
- Add new compile-time constants and update package versions
- Refactor AssetEntry upload logic to return Result and propagate errors
- Enhance error handling in ResourceStreamingProcessor uploads
- Make ResourceStreamingContext a readonly struct
- Implement IDisposable and finalizers for resource cleanup
- Overhaul AssetManagerTest with async tests and improved mocks
- Add mock implementations for graphics interfaces for testing
- Refactor MockingCommandBuffer and MockingResourceDatabase for better simulation
- Update internals visibility for unit testing
2026-05-03 17:05:52 +09:00

53 lines
1.0 KiB
C#

using Ghost.Graphics.RHI;
namespace Ghost.UnitTest.MockingEnvironment;
internal class MockingFence : IFence
{
private readonly AutoResetEvent _fenceEvent;
private ulong _currentValue;
public ulong CompletedValue => _currentValue;
public nint WaitHandle => _fenceEvent.SafeWaitHandle.DangerousGetHandle();
public string Name
{
get; set;
} = "MockingFence";
public MockingFence(ulong initialValue)
{
_fenceEvent = new AutoResetEvent(false);
_currentValue = initialValue;
}
public void Signal(ulong value)
{
if (value > _currentValue)
{
_currentValue = value;
_fenceEvent.Set();
}
}
public void WaitForValue(ulong value)
{
if (value > _currentValue)
{
_fenceEvent.WaitOne();
}
}
public Task WaitForValueAsync(ulong value)
{
return Task.Run(() => { WaitForValue(value); });
}
public void Dispose()
{
_fenceEvent.Dispose();
}
}