Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuse futures before loop in process_events_async #1781

Conversation

wpaulino
Copy link
Contributor

As per the futures::select documentation:

Futures and streams which are not already fused can be fused using the .fuse() method. Note, though, that fusing a future or stream directly in the call to select! will not be enough to prevent it from being polled after completion if the select! call is in a loop, so when select!ing in a loop, users should take care to fuse() outside of the loop.

In our case, this isn't strictly required as we would always have a new instance of the futures on each poll, but just to be safe, we follow the suggestion anyway. As a result, we generate a new future for each one that has completed, so that we can continue with execution.

As per the futures::select documentation:

> Futures and streams which are not already fused can be fused using the
> .fuse() method. Note, though, that fusing a future or stream directly
> in the call to select! will not be enough to prevent it from being
> polled after completion if the select! call is in a loop, so when
> select!ing in a loop, users should take care to fuse() outside of the
> loop.

In our case, this isn't strictly required as we would always have a new
instance of the futures on each poll, but just to be safe, we follow the
suggestion anyway. As a result, we generate a new future for each one
that has completed, so that we can continue with execution.
@codecov-commenter
Copy link

Codecov Report

Base: 90.79% // Head: 90.76% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (1369fc7) compared to base (6738fd5).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1781      +/-   ##
==========================================
- Coverage   90.79%   90.76%   -0.04%     
==========================================
  Files          87       87              
  Lines       46969    46969              
  Branches    46969    46969              
==========================================
- Hits        42646    42631      -15     
- Misses       4323     4338      +15     
Impacted Files Coverage Δ
lightning-background-processor/src/lib.rs 96.23% <ø> (ø)
lightning/src/chain/onchaintx.rs 94.71% <0.00%> (-0.92%) ⬇️
lightning/src/ln/peer_channel_encryptor.rs 93.38% <0.00%> (-0.25%) ⬇️
lightning/src/ln/functional_tests.rs 96.88% <0.00%> (-0.12%) ⬇️
lightning/src/chain/channelmonitor.rs 91.16% <0.00%> (-0.06%) ⬇️
lightning/src/ln/channelmanager.rs 85.14% <0.00%> (-0.03%) ⬇️
lightning/src/ln/msgs.rs 86.24% <0.00%> (ø)
lightning/src/ln/chan_utils.rs 94.55% <0.00%> (ø)
lightning/src/routing/gossip.rs 92.16% <0.00%> (ø)
lightning/src/routing/scoring.rs 96.61% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@wpaulino wpaulino closed this Oct 19, 2022
@wpaulino wpaulino deleted the bg-processor-fuse-future-before-loop branch October 19, 2022 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants