Skip to content

Commit

Permalink
remove parallelism-meter form signal-flow and signal-handling-pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
fembina committed Jan 15, 2025
1 parent 2b4b9c9 commit 2d18be7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
14 changes: 5 additions & 9 deletions Sources/Falko.Talkie.Signals/Flows/SignalFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ public sealed class SignalFlow : ISignalFlow

private readonly RemovableSequence<ISignalHandlingPipeline> _pipelines = new();

private readonly ParallelismMeter _pipelinesParallelismMeter = new();

private bool _disposed;

public SignalFlow()
{
TaskScheduler.UnobservedTaskException += OnUnobservedSignalPublishingException;
}
public SignalFlow() => TaskScheduler.UnobservedTaskException += OnUnobservedSignalPublishingException;

public Subscription Subscribe(ISignalHandlingPipeline handlingPipeline)
{
Expand Down Expand Up @@ -50,9 +45,10 @@ public async Task PublishAsync(Signal signal, CancellationToken cancellationToke
try
{
// ReSharper disable once InconsistentlySynchronizedField
await _pipelines.Parallelize(_pipelinesParallelismMeter)
.ForEachAsync((pipeline, scopedCancellationToken) => pipeline.TransferAsync(this, signal, scopedCancellationToken),
cancellationToken: publishCancellationToken);
await _pipelines
.Parallelize()
.ForEachAsync((pipeline, scopedCancellationToken) => pipeline
.TransferAsync(this, signal, scopedCancellationToken), publishCancellationToken);
}
catch (SignalPublishingException exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public sealed class ManySignalHandlingPipeline
{
private readonly FrozenSequence<ISignalHandler> _handlers = handlers.ToFrozenSequence();

private readonly ParallelismMeter _handlersParallelismMeter = new();

public ValueTask TransferAsync(ISignalFlow flow, Signal signal, CancellationToken cancellationToken = default)
{
if (interceptingPipeline?.TryTransfer(signal, out signal, cancellationToken) is false)
Expand All @@ -26,9 +24,10 @@ public ValueTask TransferAsync(ISignalFlow flow, Signal signal, CancellationToke

var context = new SignalContext(flow, signal);

return _handlers.Parallelize(_handlersParallelismMeter)
.ForEachAsync((handler, scopedCancellationToken) => handler.HandleAsync(context, scopedCancellationToken),
cancellationToken: cancellationToken)
return _handlers
.Parallelize()
.ForEachAsync((handler, scopedCancellationToken) => handler
.HandleAsync(context, scopedCancellationToken), cancellationToken: cancellationToken)
.AsValueTask();
}
}

0 comments on commit 2d18be7

Please sign in to comment.