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

Port to event-listener v5.0 #48

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ name = "broadcast_bench"
[features]

[dependencies]
event-listener = "3"
event-listener-strategy = "0.1.0"
event-listener = "5.0.0"
event-listener-strategy = "0.5.0"
futures-core = "0.3.21"

[dev-dependencies]
Expand Down
23 changes: 11 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
//!
#![forbid(unsafe_code)]
#![deny(missing_debug_implementations, nonstandard_style, rust_2018_idioms)]
#![warn(rustdoc::missing_doc_code_examples, unreachable_pub)]

Check warning on line 96 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build_and_test (ubuntu-latest, nightly)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 96 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build_and_test (ubuntu-latest, beta)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 96 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build_and_test (ubuntu-latest, stable)

unknown lint: `rustdoc::missing_doc_code_examples`
#![doc(
html_favicon_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png"
)]
Expand Down Expand Up @@ -785,7 +785,7 @@
pos: u64,

/// Listens for a send or close event to unblock this stream.
listener: Option<Pin<Box<EventListener>>>,
listener: Option<EventListener>,
}

impl<T> Receiver<T> {
Expand Down Expand Up @@ -1599,8 +1599,7 @@
#[derive(Debug)]
struct SendInner<'a, T> {
sender: &'a Sender<T>,
// TODO: Remove the Pin<Box<>> at the next breaking release and make this type !Unpin
listener: Option<Pin<Box<EventListener>>>,
listener: Option<EventListener>,
msg: Option<T>,
}

Expand All @@ -1610,7 +1609,7 @@
type Output = Result<Option<T>, SendError<T>>;

fn poll_with_strategy<'x, S: event_listener_strategy::Strategy<'x>>(
self: Pin<&'x mut Self>,
self: Pin<&mut Self>,
strategy: &mut S,
context: &mut S::Context,
) -> Poll<Self::Output> {
Expand Down Expand Up @@ -1641,15 +1640,15 @@
}

// Sending failed - now start listening for notifications or wait for one.
match &mut this.listener {
match &this.listener {
None => {
// Start listening and then try sending again.
let inner = inner.write().unwrap();
this.listener = Some(inner.send_ops.listen());
}
Some(l) => {
Some(_) => {
// Wait for a notification.
ready!(strategy.poll(l.as_mut(), context));
ready!(strategy.poll(&mut this.listener, context));
this.listener = None;
}
}
Expand All @@ -1668,7 +1667,7 @@
#[derive(Debug)]
struct RecvInner<'a, T> {
receiver: &'a mut Receiver<T>,
listener: Option<Pin<Box<EventListener>>>,
listener: Option<EventListener>,
}

impl<'a, T> Unpin for RecvInner<'a, T> {}
Expand All @@ -1677,7 +1676,7 @@
type Output = Result<T, RecvError>;

fn poll_with_strategy<'x, S: event_listener_strategy::Strategy<'x>>(
self: Pin<&'x mut Self>,
self: Pin<&mut Self>,
strategy: &mut S,
context: &mut S::Context,
) -> Poll<Self::Output> {
Expand All @@ -1695,17 +1694,17 @@
}

// Receiving failed - now start listening for notifications or wait for one.
match &mut this.listener {
match &this.listener {
None => {
// Start listening and then try receiving again.
this.listener = {
let inner = this.receiver.inner.write().unwrap();
Some(inner.recv_ops.listen())
};
}
Some(l) => {
Some(_) => {
// Wait for a notification.
ready!(strategy.poll(l.as_mut(), context));
ready!(strategy.poll(&mut this.listener, context));
this.listener = None;
}
}
Expand Down
Loading