Files
MicrosoftIris/UIXrender/Engine/ContextRegistry.cs
T

22 lines
1019 B
C#
Raw Normal View History

2026-07-22 07:55:15 -05:00
using System.Collections.Concurrent;
using Microsoft.Iris.Render.Interop;
namespace Microsoft.Iris.Render.Engine;
2026-07-22 18:34:57 -05:00
// Maps a registered ContextID to the handler it should receive deliveries on via
// SendBuffer -- the smallest coherent slice of "Engine core" (see
// logs/UIXrender/EngineCore.md) needed for StartRenderThread and SendBuffer to mean
// anything together. Holds an ordinary delegate now (not a raw callback pointer) --
// pointer marshaling, where it's still needed for native callers, lives entirely in
// Interop/EngineApi.cs.
2026-07-22 07:55:15 -05:00
internal static class ContextRegistry
{
2026-07-22 18:34:57 -05:00
private static readonly ConcurrentDictionary<uint, BufferReceivedHandler> s_contexts = new();
2026-07-22 07:55:15 -05:00
2026-07-22 18:34:57 -05:00
public static void Register(ContextID id, BufferReceivedHandler handler) => s_contexts[id.value] = handler;
2026-07-22 07:55:15 -05:00
public static void Unregister(ContextID id) => s_contexts.TryRemove(id.value, out _);
2026-07-22 18:34:57 -05:00
public static bool TryGet(ContextID id, out BufferReceivedHandler handler) => s_contexts.TryGetValue(id.value, out handler);
2026-07-22 07:55:15 -05:00
}