-
Notifications
You must be signed in to change notification settings - Fork 384
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
Add a parallel async event handler to OnionMessenger and pass it directly to BackgroundProcessor #3060
Merged
TheBlueMatt
merged 8 commits into
lightningdevkit:main
from
TheBlueMatt:2024-05-parallel-async-om-events
Jun 4, 2024
Merged
Add a parallel async event handler to OnionMessenger and pass it directly to BackgroundProcessor #3060
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
20f2dab
Create an `AOnionMessenger` trait similar to our other `AStruct`s
TheBlueMatt 98022e6
Add a utility to poll multiple futures simultaneously
TheBlueMatt c1ea761
f docs
TheBlueMatt 9ef6174
Store `OnionMessenger` events in different `Vec`s
TheBlueMatt 3abec4f
Add a parallel async event handler to `OnionMessenger`
TheBlueMatt 92bf460
Switch to using the `OnionMessenger` directly in BP
TheBlueMatt f96fbdd
f fix imports in BP
TheBlueMatt fadb268
Drop `EventsProvider` bounds on `OnionMessageHandler`s
TheBlueMatt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// This file is Copyright its original authors, visible in version control | ||
// history. | ||
// | ||
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE | ||
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. | ||
// You may not use this file except in accordance with one or both of these | ||
// licenses. | ||
|
||
//! Some utilities to make working with the standard library's [`Future`]s easier | ||
|
||
use crate::prelude::*; | ||
use core::future::Future; | ||
use core::marker::Unpin; | ||
use core::pin::Pin; | ||
use core::task::{Context, Poll}; | ||
|
||
pub(crate) struct MultiFuturePoller<F: Future<Output = ()> + Unpin>(pub Vec<Option<F>>); | ||
|
||
impl<F: Future<Output = ()> + Unpin> Future for MultiFuturePoller<F> { | ||
type Output = (); | ||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { | ||
let mut have_pending_futures = false; | ||
for fut_option in self.get_mut().0.iter_mut() { | ||
let mut fut = match fut_option.take() { | ||
None => continue, | ||
Some(fut) => fut, | ||
}; | ||
match Pin::new(&mut fut).poll(cx) { | ||
Poll::Ready(()) => {}, | ||
Poll::Pending => { | ||
have_pending_futures = true; | ||
*fut_option = Some(fut); | ||
}, | ||
} | ||
} | ||
if have_pending_futures { | ||
Poll::Pending | ||
} else { | ||
Poll::Ready(()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: end sentences in periods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think they're full sentences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AChannelManager
's docs have the same sentence structure and use periods. Feel free to ignore, though.