| | | 1 | | using CounterpointCollective.Collections; |
| | | 2 | | using System.Threading.Tasks.Dataflow; |
| | | 3 | | |
| | | 4 | | namespace CounterpointCollective.Dataflow.Notifying |
| | | 5 | | { |
| | | 6 | | public record NotifyingSourceBlockHooks { |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Callback to configure the dispatching of notification events. |
| | | 10 | | /// Defaults to UseAsynchronousDispatch. |
| | | 11 | | /// </summary> |
| | | 12 | | public Action<ICoalescingQueue> ConfigureDispatching { get; set; } = q => q.UseAsynchronousDispatch(); |
| | | 13 | | } |
| | | 14 | | |
| | | 15 | | public record NotifyingSourceBlockHooks<T>(ISourceBlock<T> SourceBlock): NotifyingSourceBlockHooks |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// This Action will be executed when a messages are sent from the source block. |
| | | 19 | | /// </summary> |
| | | 20 | | public Action<int>? OnDeliveringMessages { get; set; } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// This Action will be executed when a linked target released its reservation. |
| | | 24 | | /// </summary> |
| | | 25 | | public Action? OnReservationReleased { get; set; } |
| | | 26 | | } |
| | | 27 | | |
| | 2 | 28 | | public record NotifyingSourceBlockAsyncHooks<T>(ISourceBlock<T> SourceBlock) : NotifyingSourceBlockHooks |
| | | 29 | | { |
| | | 30 | | /// <summary> |
| | | 31 | | /// This Action will be executed when a messages are sent from the source block. |
| | | 32 | | /// </summary> |
| | 3 | 33 | | public Func<int, ValueTask>? OnDeliveringMessagesAsync { get; set; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// This Action will be executed when a linked target released its reservation. |
| | | 37 | | /// </summary> |
| | 1 | 38 | | public Func<ValueTask>? OnReservationReleasedAsync { get; set; } |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | public delegate void ConfigureHooks<T>(NotifyingSourceBlockHooks<T> hooks); |
| | | 42 | | public delegate void ConfigureAsyncHooks<T>(NotifyingSourceBlockAsyncHooks<T> hooks); |
| | | 43 | | |
| | | 44 | | } |