perf(eventbus): remove inline allocations and expose binding snapshots
This commit is contained in:
@@ -14,6 +14,7 @@ namespace ShrinkEventBus
|
||||
internal interface IShrinkEventChannel
|
||||
{
|
||||
int Count { get; }
|
||||
void CaptureBindings(List<(Type EventType, System.Reflection.MethodInfo Handler)> bindings);
|
||||
bool RemoveSubscription(long subscriptionId);
|
||||
void Clear();
|
||||
void DetachSlot(int slot);
|
||||
@@ -87,6 +88,15 @@ namespace ShrinkEventBus
|
||||
private Action<TEvent>? _syncDispatcher;
|
||||
|
||||
public int Count => _snapshot.Length;
|
||||
public void CaptureBindings(List<(Type EventType, System.Reflection.MethodInfo Handler)> bindings)
|
||||
{
|
||||
var snapshot = _snapshot;
|
||||
foreach (var entry in snapshot)
|
||||
{
|
||||
var method = entry.SyncHandler?.Method ?? entry.AsyncHandler?.Method;
|
||||
if (method != null) bindings.Add((typeof(TEvent), method));
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(long subscriptionId, long registrationOrder, Action<TEvent> handler,
|
||||
ShrinkSubscribeDescriptor descriptor)
|
||||
|
||||
Reference in New Issue
Block a user