diff --git a/Cargo.lock.msrv b/Cargo.lock.msrv index d987867..ecf1fa9 100644 --- a/Cargo.lock.msrv +++ b/Cargo.lock.msrv @@ -253,6 +253,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-io", + "futures-task", "futures-util", "gio", "glib", @@ -585,9 +586,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -595,9 +596,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" @@ -612,9 +613,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" @@ -646,9 +647,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -657,21 +658,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", diff --git a/Cargo.toml b/Cargo.toml index d580945..70812c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ features = ["async-std-runtime", "tokio-runtime", "gio-runtime", "async-tls", "a [dependencies] log = "0.4" futures-core = { version = "0.3", default-features = false } +futures-task = { version = "0.3.31", default-features = false } atomic-waker = { version = "1.1", default-features = false } futures-io = { version = "0.3", default-features = false, features = ["std"] } pin-project-lite = "0.2" diff --git a/src/compat.rs b/src/compat.rs index c2fe19a..fdc8857 100644 --- a/src/compat.rs +++ b/src/compat.rs @@ -2,10 +2,11 @@ use log::*; use std::io::{Read, Write}; use std::pin::Pin; -use std::task::{Context, Poll, Wake, Waker}; +use std::task::{Context, Poll, Waker}; use atomic_waker::AtomicWaker; use futures_io::{AsyncRead, AsyncWrite}; +use futures_task::{waker_ref, ArcWake}; use std::sync::Arc; use tungstenite::Error as WsError; @@ -109,14 +110,10 @@ struct WakerProxy { write_waker: AtomicWaker, } -impl Wake for WakerProxy { - fn wake(self: Arc) { - self.wake_by_ref() - } - - fn wake_by_ref(self: &Arc) { - self.read_waker.wake(); - self.write_waker.wake(); +impl ArcWake for WakerProxy { + fn wake_by_ref(arc_self: &Arc) { + arc_self.read_waker.wake(); + arc_self.write_waker.wake(); } } @@ -131,8 +128,8 @@ where #[cfg(feature = "verbose-logging")] trace!("{}:{} AllowStd.with_context", file!(), line!()); let waker = match kind { - ContextWaker::Read => Waker::from(self.read_waker_proxy.clone()), - ContextWaker::Write => Waker::from(self.write_waker_proxy.clone()), + ContextWaker::Read => waker_ref(&self.read_waker_proxy), + ContextWaker::Write => waker_ref(&self.write_waker_proxy), }; let mut context = Context::from_waker(&waker); f(&mut context, Pin::new(&mut self.inner))