Skip to content

Commit

Permalink
Paralellize broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
longfin committed Jun 18, 2021
1 parent eaabdcf commit 1a8b758
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ To be released.
- `ActionEvaluator<T>.EvaluateActions()` now throws an unmanaged exception
if `OutOfMemoryException` is caught from `IAction.Execute()`.
[[#1320], [#1343]]
- Improved performance of broadcasting using `Swarm<T>`. [[#1334]]

### Bug fixes

Expand Down Expand Up @@ -299,6 +300,7 @@ To be released.
[#1320]: https://github.com/planetarium/libplanet/issues/1320
[#1325]: https://github.com/planetarium/libplanet/pull/1325
[#1328]: https://github.com/planetarium/libplanet/pull/1328
[#1334]: https://github.com/planetarium/libplanet/pull/1334
[#1339]: https://github.com/planetarium/libplanet/issues/1339
[#1342]: https://github.com/planetarium/libplanet/pull/1342
[#1343]: https://github.com/planetarium/libplanet/pull/1343
Expand Down
4 changes: 2 additions & 2 deletions Libplanet/Net/Transports/NetMQTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ private void DoBroadcast(object sender, NetMQQueueEventArgs<(Address?, Message)>
DateTimeOffset.UtcNow,
_appProtocolVersion);

foreach (BoundPeer peer in peers)
peers.AsParallel().ForAll(peer =>
{
string endpoint = peer.ToNetMQAddress();
if (!_dealers.TryGetValue(peer.Address, out DealerSocket dealer) ||
Expand All @@ -647,7 +647,7 @@ private void DoBroadcast(object sender, NetMQQueueEventArgs<(Address?, Message)>
dealer.Dispose();
_dealers.TryRemove(peer.Address, out _);
}
}
});
}
catch (Exception exc)
{
Expand Down

0 comments on commit 1a8b758

Please sign in to comment.