| | | 1 | | using CounterpointCollective.Dataflow.Internal; |
| | | 2 | | using System; |
| | | 3 | | using System.Threading.Tasks; |
| | | 4 | | using System.Threading.Tasks.Dataflow; |
| | | 5 | | |
| | | 6 | | namespace CounterpointCollective.Dataflow.Encapsulation |
| | | 7 | | { |
| | | 8 | | /// <exclude /> |
| | | 9 | | public static class LinkToExtensions |
| | | 10 | | { |
| | | 11 | | public static IDisposable LinkToWithCustomCompletion<T>(this ISourceBlock<T> s, Task customCompletion, ITargetBl |
| | 547 | 12 | | => s.LinkTo( |
| | 547 | 13 | | new TargetWrapper<T>(customCompletion, target), |
| | 547 | 14 | | options |
| | 547 | 15 | | ); |
| | | 16 | | |
| | 547 | 17 | | private class TargetWrapper<T>(Task customCompletion, ITargetBlock<T> target) : ITargetBlock<T> |
| | | 18 | | { |
| | 0 | 19 | | public Task Completion => target.Completion; |
| | | 20 | | |
| | 23 | 21 | | public void Complete() => customCompletion.PropagateCompletion(target); |
| | 6 | 22 | | public void Fault(Exception exception) => customCompletion.PropagateCompletion(target); |
| | | 23 | | public DataflowMessageStatus OfferMessage(DataflowMessageHeader messageHeader, T messageValue, ISourceBlock< |
| | 200878 | 24 | | => target.OfferMessage(messageHeader, messageValue, source, consumeToAccept); |
| | | 25 | | |
| | | 26 | | } |
| | | 27 | | } |
| | | 28 | | } |