feat: update Godot integration and coordinated package dependencies
This commit is contained in:
15 files changed
+576
-55
No files matched your search
+52
-7
@@ -133,6 +133,30 @@ namespace ShrinkEventBus
|
||||
CancellationToken cancellationToken = default)
|
||||
where TEvent : IShrinkEvent => DefaultBus.PostAsync(eventData, cancellationToken);
|
||||
|
||||
public static ShrinkPostResult PostDeferred<TEvent>(IShrinkEventBus bus, TEvent eventData)
|
||||
where TEvent : IShrinkEvent
|
||||
{
|
||||
if (bus == null)
|
||||
throw new ArgumentNullException(nameof(bus));
|
||||
return bus is ShrinkEventBusInstance instance
|
||||
? instance.PostDeferred(in eventData)
|
||||
: ShrinkPostResult.Rejected(ShrinkPostFailure.DeferredUnsupported);
|
||||
}
|
||||
|
||||
public static IDisposable ObserveDiagnostics(Action<ShrinkEventDiagnostic> observer)
|
||||
{
|
||||
if (observer == null)
|
||||
throw new ArgumentNullException(nameof(observer));
|
||||
|
||||
void Handler(ShrinkEventTrace trace) => observer(new ShrinkEventDiagnostic(
|
||||
trace.TimestampUtc, trace.EventType, trace.BusKey, trace.Scheduler,
|
||||
trace.DispatchMode, trace.ThreadId, trace.ElapsedTimestampTicks,
|
||||
trace.Result, trace.IsAsync));
|
||||
|
||||
DetailedPosted += Handler;
|
||||
return new DiagnosticSubscription(Handler);
|
||||
}
|
||||
|
||||
public static IDisposable Attach(object target, ShrinkBusKey? defaultBus = null)
|
||||
{
|
||||
if (target == null)
|
||||
@@ -191,17 +215,38 @@ namespace ShrinkEventBus
|
||||
var observers = Volatile.Read(ref _detailedPosted);
|
||||
if (observers == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
observers(trace);
|
||||
}
|
||||
catch (Exception exception)
|
||||
var invocationList = observers.GetInvocationList();
|
||||
for (var i = 0; i < invocationList.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Action<ShrinkEventTrace>)invocationList[i])(trace);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
UnityEngine.Debug.LogException(exception);
|
||||
UnityEngine.Debug.LogException(exception);
|
||||
#else
|
||||
System.Diagnostics.Trace.TraceError(exception.ToString());
|
||||
System.Diagnostics.Trace.TraceError(exception.ToString());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class DiagnosticSubscription : IDisposable
|
||||
{
|
||||
private Action<ShrinkEventTrace>? _handler;
|
||||
|
||||
public DiagnosticSubscription(Action<ShrinkEventTrace> handler)
|
||||
{
|
||||
_handler = handler;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
var handler = Interlocked.Exchange(ref _handler, null);
|
||||
if (handler != null)
|
||||
DetailedPosted -= handler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user