From 556411ea554b4ab60f18fecb668fa7f529306865 Mon Sep 17 00:00:00 2001 From: DataTriny Date: Tue, 14 Mar 2023 21:43:54 +0100 Subject: [PATCH 1/2] feat: Add features for async runtimes on Linux --- Cargo.lock | 153 +++++++++++++++++++++++++++----- platforms/unix/Cargo.toml | 12 ++- platforms/unix/src/adapter.rs | 106 +++++++++++++--------- platforms/unix/src/atspi/bus.rs | 60 +++++++------ platforms/unix/src/util.rs | 22 +++++ platforms/winit/Cargo.toml | 8 +- 6 files changed, 267 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 489ca9b6f..beb27dd00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,7 +64,9 @@ dependencies = [ "async-channel", "atspi", "futures-lite", + "lazy_static", "serde", + "tokio", "zbus", ] @@ -90,6 +92,7 @@ dependencies = [ "accesskit_macos", "accesskit_unix", "accesskit_windows", + "tokio", "winit", ] @@ -228,7 +231,7 @@ checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -245,7 +248,7 @@ checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -278,7 +281,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fb4870a32c0eaa17e35bca0e6b16020635157121fb7d45593d242c295bc768" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -353,6 +356,12 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + [[package]] name = "calloop" version = "0.10.5" @@ -482,7 +491,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -560,7 +569,7 @@ checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -571,7 +580,7 @@ checksum = "1940ea32e14d489b401074558be4567f35ca9507c4628b4b3fd6fe6eb2ca7b88" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -717,6 +726,15 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.3.1" @@ -757,7 +775,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76e86b86ae312accbf05ade23ce76b625e0e47a255712b7414037385a1c05380" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.1", "libc", "windows-sys 0.45.0", ] @@ -820,6 +838,16 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.17" @@ -967,6 +995,16 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + [[package]] name = "num_enum" version = "0.5.11" @@ -985,7 +1023,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1057,6 +1095,29 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "windows-sys 0.45.0", +] + [[package]] name = "paste" version = "1.0.12" @@ -1272,7 +1333,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 1.0.109", ] [[package]] @@ -1317,7 +1378,7 @@ checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1328,7 +1389,7 @@ checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1350,7 +1411,7 @@ checksum = "395627de918015623b32e7669714206363a7fc00382bf477e72c1f7533e8eafc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1364,6 +1425,15 @@ dependencies = [ "digest", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "slab" version = "0.4.8" @@ -1440,6 +1510,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.4.0" @@ -1470,7 +1551,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1498,6 +1579,36 @@ dependencies = [ "strict-num", ] +[[package]] +name = "tokio" +version = "1.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +dependencies = [ + "autocfg", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.45.0", +] + +[[package]] +name = "tokio-macros" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + [[package]] name = "toml_datetime" version = "0.6.1" @@ -1535,7 +1646,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1620,7 +1731,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -1642,7 +1753,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1777,7 +1888,7 @@ checksum = "6ce87ca8e3417b02dc2a8a22769306658670ec92d78f1bd420d6310a67c245c6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1788,7 +1899,7 @@ checksum = "853f69a591ecd4f810d29f17e902d40e349fb05b0b11fff63b08b826bfe39c7f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1991,7 +2102,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 1.0.109", "zvariant_utils", ] @@ -2029,7 +2140,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "zvariant_utils", ] @@ -2041,5 +2152,5 @@ checksum = "53b22993dbc4d128a17a3b6c92f1c63872dd67198537ee728d8b5d7c40640a8b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] diff --git a/platforms/unix/Cargo.toml b/platforms/unix/Cargo.toml index c17c888e7..8e515b4ac 100644 --- a/platforms/unix/Cargo.toml +++ b/platforms/unix/Cargo.toml @@ -10,12 +10,18 @@ repository = "https://github.com/AccessKit/accesskit" readme = "README.md" edition = "2021" +[features] +default = ["async-io"] +async-io = ["zbus/async-io"] +tokio = ["dep:lazy_static", "dep:tokio"] + [dependencies] accesskit = { version = "0.11.0", path = "../../common" } accesskit_consumer = { version = "0.15.0", path = "../../consumer" } async-channel = "1.8.0" -atspi = "0.10.1" +atspi = { version = "0.10.1", default-features = false } futures-lite = "1.12.0" +lazy_static = { version = "1.4.0", optional = true } serde = "1.0" -zbus = "3.6" - +tokio = { version = "1.10.0", optional = true, features = ["rt-multi-thread", "net", "time"] } +zbus = { version = "3.6", default-features = false } diff --git a/platforms/unix/src/adapter.rs b/platforms/unix/src/adapter.rs index 53e901266..a549d7fe3 100644 --- a/platforms/unix/src/adapter.rs +++ b/platforms/unix/src/adapter.rs @@ -13,7 +13,7 @@ use crate::{ }, context::Context, node::{filter, filter_detached, NodeWrapper, PlatformNode}, - util::AppContext, + util::{block_on, AppContext}, }; use accesskit::{ActionHandler, NodeId, Rect, Role, TreeUpdate}; use accesskit_consumer::{DetachedNode, FilterResult, Node, Tree, TreeChangeHandler, TreeState}; @@ -39,10 +39,12 @@ impl Adapter { initial_state: impl 'static + FnOnce() -> TreeUpdate, action_handler: Box, ) -> Option { - let mut atspi_bus = Bus::a11y_bus()?; + let mut atspi_bus = block_on(async { Bus::a11y_bus().await })?; let (event_sender, event_receiver) = async_channel::unbounded(); let atspi_bus_copy = atspi_bus.clone(); - let event_task = atspi_bus.connection().inner().executor().spawn( + #[cfg(feature = "tokio")] + let _guard = crate::util::TOKIO_RT.enter(); + let event_task = atspi_bus.connection().executor().spawn( async move { handle_events(atspi_bus_copy, event_receiver).await; }, @@ -51,7 +53,7 @@ impl Adapter { let tree = Tree::new(initial_state()); let app_context = AppContext::new(app_name, toolkit_name, toolkit_version); let context = Context::new(tree, action_handler, app_context); - atspi_bus.register_root_node(&context).ok()?; + block_on(async { atspi_bus.register_root_node(&context).await.ok() })?; let adapter = Adapter { atspi_bus, _event_task: event_task, @@ -85,31 +87,47 @@ impl Adapter { fn register_interfaces(&self, id: NodeId, new_interfaces: InterfaceSet) -> zbus::Result { let path = format!("{}{}", ACCESSIBLE_PATH_PREFIX, ObjectId::from(id).as_str()); if new_interfaces.contains(Interface::Accessible) { - self.atspi_bus.register_interface( - &path, - AccessibleInterface::new( - self.atspi_bus.unique_name().to_owned(), - PlatformNode::new(&self.context, id), - ), - )?; + block_on(async { + self.atspi_bus + .register_interface( + &path, + AccessibleInterface::new( + self.atspi_bus.unique_name().to_owned(), + PlatformNode::new(&self.context, id), + ), + ) + .await + })?; } if new_interfaces.contains(Interface::Action) { - self.atspi_bus.register_interface( - &path, - ActionInterface::new(PlatformNode::new(&self.context, id)), - )?; + block_on(async { + self.atspi_bus + .register_interface( + &path, + ActionInterface::new(PlatformNode::new(&self.context, id)), + ) + .await + })?; } if new_interfaces.contains(Interface::Component) { - self.atspi_bus.register_interface( - &path, - ComponentInterface::new(PlatformNode::new(&self.context, id)), - )?; + block_on(async { + self.atspi_bus + .register_interface( + &path, + ComponentInterface::new(PlatformNode::new(&self.context, id)), + ) + .await + })?; } if new_interfaces.contains(Interface::Value) { - self.atspi_bus.register_interface( - &path, - ValueInterface::new(PlatformNode::new(&self.context, id)), - )?; + block_on(async { + self.atspi_bus + .register_interface( + &path, + ValueInterface::new(PlatformNode::new(&self.context, id)), + ) + .await + })?; } Ok(true) } @@ -119,24 +137,30 @@ impl Adapter { id: &ObjectId, old_interfaces: InterfaceSet, ) -> zbus::Result { - let path = format!("{}{}", ACCESSIBLE_PATH_PREFIX, id.as_str()); - if old_interfaces.contains(Interface::Accessible) { - self.atspi_bus - .unregister_interface::>(&path)?; - } - if old_interfaces.contains(Interface::Action) { - self.atspi_bus - .unregister_interface::(&path)?; - } - if old_interfaces.contains(Interface::Component) { - self.atspi_bus - .unregister_interface::(&path)?; - } - if old_interfaces.contains(Interface::Value) { - self.atspi_bus - .unregister_interface::(&path)?; - } - Ok(true) + block_on(async { + let path = format!("{}{}", ACCESSIBLE_PATH_PREFIX, id.as_str()); + if old_interfaces.contains(Interface::Accessible) { + self.atspi_bus + .unregister_interface::>(&path) + .await?; + } + if old_interfaces.contains(Interface::Action) { + self.atspi_bus + .unregister_interface::(&path) + .await?; + } + if old_interfaces.contains(Interface::Component) { + self.atspi_bus + .unregister_interface::(&path) + .await?; + } + if old_interfaces.contains(Interface::Value) { + self.atspi_bus + .unregister_interface::(&path) + .await?; + } + Ok(true) + }) } pub fn set_root_window_bounds(&self, outer: Rect, inner: Rect) { diff --git a/platforms/unix/src/atspi/bus.rs b/platforms/unix/src/atspi/bus.rs index cfe08f3c8..1e5d55d76 100644 --- a/platforms/unix/src/atspi/bus.rs +++ b/platforms/unix/src/atspi/bus.rs @@ -8,26 +8,25 @@ use crate::{ context::Context, PlatformRootNode, }; -use atspi::{bus::BusProxyBlocking, socket::SocketProxyBlocking, EventBody}; +use atspi::{bus::BusProxy, socket::SocketProxy, EventBody}; use serde::Serialize; use std::{collections::HashMap, env::var, sync::Arc}; use zbus::{ - blocking::{Connection, ConnectionBuilder}, names::{BusName, InterfaceName, MemberName, OwnedUniqueName}, zvariant::{ObjectPath, Str, Value}, - Address, Result, + Address, Connection, ConnectionBuilder, Result, }; #[derive(Clone)] pub(crate) struct Bus { conn: Connection, - socket_proxy: SocketProxyBlocking<'static>, + socket_proxy: SocketProxy<'static>, } impl Bus { - pub fn a11y_bus() -> Option { - let conn = a11y_bus()?; - let socket_proxy = SocketProxyBlocking::new(&conn).ok()?; + pub async fn a11y_bus() -> Option { + let conn = a11y_bus().await?; + let socket_proxy = SocketProxy::new(&conn).await.ok()?; Some(Bus { conn, socket_proxy }) } @@ -39,36 +38,44 @@ impl Bus { self.conn.unique_name().unwrap() } - pub fn register_interface(&self, path: &str, interface: T) -> Result + pub async fn register_interface(&self, path: &str, interface: T) -> Result where T: zbus::Interface, { - self.conn.object_server().at(path, interface) + self.conn.object_server().at(path, interface).await } - pub fn unregister_interface(&self, path: &str) -> Result + pub async fn unregister_interface(&self, path: &str) -> Result where T: zbus::Interface, { - self.conn.object_server().remove::(path) + self.conn.object_server().remove::(path).await } - pub fn register_root_node(&mut self, context: &Arc) -> Result { + pub async fn register_root_node(&mut self, context: &Arc) -> Result { let node = PlatformRootNode::new(context); let path = format!("{}{}", ACCESSIBLE_PATH_PREFIX, ObjectId::root().as_str()); let registered = self .conn .object_server() - .at(path.clone(), ApplicationInterface(node.clone()))? - && self.conn.object_server().at( - path, - AccessibleInterface::new(self.unique_name().to_owned(), node), - )?; + .at(path.clone(), ApplicationInterface(node.clone())) + .await? + && self + .conn + .object_server() + .at( + path, + AccessibleInterface::new(self.unique_name().to_owned(), node), + ) + .await?; if registered { - let desktop = self.socket_proxy.embed(&( - self.unique_name().as_str(), - ObjectPath::from_str_unchecked(ROOT_PATH), - ))?; + let desktop = self + .socket_proxy + .embed(&( + self.unique_name().as_str(), + ObjectPath::from_str_unchecked(ROOT_PATH), + )) + .await?; context.app_context.write().unwrap().desktop_address = Some(desktop.into()); Ok(true) } else { @@ -219,7 +226,6 @@ impl Bus { ) -> Result<()> { let path = format!("{}{}", ACCESSIBLE_PATH_PREFIX, id.as_str()); self.conn - .inner() .emit_signal( Option::::None, path, @@ -231,17 +237,19 @@ impl Bus { } } -fn a11y_bus() -> Option { +async fn a11y_bus() -> Option { let address = match var("AT_SPI_BUS_ADDRESS") { Ok(address) if !address.is_empty() => address, _ => { - let session_bus = Connection::session().ok()?; - BusProxyBlocking::new(&session_bus) + let session_bus = Connection::session().await.ok()?; + BusProxy::new(&session_bus) + .await .ok()? .get_address() + .await .ok()? } }; let address: Address = address.as_str().try_into().ok()?; - ConnectionBuilder::address(address).ok()?.build().ok() + ConnectionBuilder::address(address).ok()?.build().await.ok() } diff --git a/platforms/unix/src/util.rs b/platforms/unix/src/util.rs index 995b57a9b..0cb1de9fc 100644 --- a/platforms/unix/src/util.rs +++ b/platforms/unix/src/util.rs @@ -7,6 +7,28 @@ use crate::atspi::OwnedObjectAddress; use accesskit::{Point, Rect}; use atspi::CoordType; +#[cfg(not(feature = "tokio"))] +pub(crate) fn block_on(future: F) -> F::Output { + zbus::block_on(future) +} + +#[cfg(feature = "tokio")] +lazy_static::lazy_static! { + pub(crate) static ref TOKIO_RT: tokio::runtime::Runtime = { + tokio::runtime::Builder::new_multi_thread() + .worker_threads(1) + .enable_io() + .enable_time() + .build() + .expect("launch of single-threaded tokio runtime") + }; +} + +#[cfg(feature = "tokio")] +pub(crate) fn block_on(future: F) -> F::Output { + TOKIO_RT.block_on(future) +} + pub(crate) struct AppContext { pub(crate) name: String, pub(crate) toolkit_name: String, diff --git a/platforms/winit/Cargo.toml b/platforms/winit/Cargo.toml index 0f9a98cf0..dddab791c 100644 --- a/platforms/winit/Cargo.toml +++ b/platforms/winit/Cargo.toml @@ -11,7 +11,9 @@ readme = "README.md" edition = "2021" [features] -default = ["accesskit_unix"] +default = ["accesskit_unix", "async-io"] +async-io = ["accesskit_unix/async-io"] +tokio = ["accesskit_unix/tokio"] [dependencies] accesskit = { version = "0.11.0", path = "../../common" } @@ -24,8 +26,8 @@ accesskit_windows = { version = "0.14.0", path = "../windows" } accesskit_macos = { version = "0.7.0", path = "../macos" } [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] -accesskit_unix = { version = "0.4.0", path = "../unix", optional = true } +accesskit_unix = { version = "0.4.0", path = "../unix", optional = true, default-features = false } [dev-dependencies] +tokio = { version = "1", features = ["full"] } winit = "0.28" - From 30870e410773f18bf0f39543a5ca0e42eb2b73b8 Mon Sep 17 00:00:00 2001 From: DataTriny Date: Sun, 21 May 2023 11:23:14 +0200 Subject: [PATCH 2/2] Address review comments --- Cargo.lock | 113 ++++++++----------------------------- platforms/unix/Cargo.toml | 4 +- platforms/unix/src/util.rs | 20 +++---- platforms/winit/Cargo.toml | 1 - 4 files changed, 36 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index beb27dd00..9c224bfa1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,7 +64,7 @@ dependencies = [ "async-channel", "atspi", "futures-lite", - "lazy_static", + "once_cell", "serde", "tokio", "zbus", @@ -92,7 +92,6 @@ dependencies = [ "accesskit_macos", "accesskit_unix", "accesskit_windows", - "tokio", "winit", ] @@ -231,7 +230,7 @@ checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -248,7 +247,7 @@ checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -281,7 +280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fb4870a32c0eaa17e35bca0e6b16020635157121fb7d45593d242c295bc768" dependencies = [ "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -491,7 +490,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -569,7 +568,7 @@ checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -580,7 +579,7 @@ checksum = "1940ea32e14d489b401074558be4567f35ca9507c4628b4b3fd6fe6eb2ca7b88" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -838,16 +837,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.17" @@ -1023,7 +1012,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -1095,29 +1084,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "windows-sys 0.45.0", -] - [[package]] name = "paste" version = "1.0.12" @@ -1333,7 +1299,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 1.0.109", + "syn", ] [[package]] @@ -1378,7 +1344,7 @@ checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -1389,7 +1355,7 @@ checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -1411,7 +1377,7 @@ checksum = "395627de918015623b32e7669714206363a7fc00382bf477e72c1f7533e8eafc" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -1425,15 +1391,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - [[package]] name = "slab" version = "0.4.8" @@ -1510,17 +1467,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "syn" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "tempfile" version = "3.4.0" @@ -1551,7 +1497,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -1590,25 +1536,12 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2", - "tokio-macros", + "tracing", "windows-sys 0.45.0", ] -[[package]] -name = "tokio-macros" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.12", -] - [[package]] name = "toml_datetime" version = "0.6.1" @@ -1646,7 +1579,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -1731,7 +1664,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn", "wasm-bindgen-shared", ] @@ -1753,7 +1686,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1888,7 +1821,7 @@ checksum = "6ce87ca8e3417b02dc2a8a22769306658670ec92d78f1bd420d6310a67c245c6" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -1899,7 +1832,7 @@ checksum = "853f69a591ecd4f810d29f17e902d40e349fb05b0b11fff63b08b826bfe39c7f" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -2076,6 +2009,7 @@ dependencies = [ "futures-sink", "futures-util", "hex", + "lazy_static", "nix 0.26.2", "once_cell", "ordered-stream", @@ -2084,6 +2018,7 @@ dependencies = [ "serde_repr", "sha1", "static_assertions", + "tokio", "tracing", "uds_windows", "winapi", @@ -2102,7 +2037,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 1.0.109", + "syn", "zvariant_utils", ] @@ -2140,7 +2075,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn", "zvariant_utils", ] @@ -2152,5 +2087,5 @@ checksum = "53b22993dbc4d128a17a3b6c92f1c63872dd67198537ee728d8b5d7c40640a8b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] diff --git a/platforms/unix/Cargo.toml b/platforms/unix/Cargo.toml index 8e515b4ac..befd92721 100644 --- a/platforms/unix/Cargo.toml +++ b/platforms/unix/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" [features] default = ["async-io"] async-io = ["zbus/async-io"] -tokio = ["dep:lazy_static", "dep:tokio"] +tokio = ["dep:once_cell", "dep:tokio", "zbus/tokio"] [dependencies] accesskit = { version = "0.11.0", path = "../../common" } @@ -21,7 +21,7 @@ accesskit_consumer = { version = "0.15.0", path = "../../consumer" } async-channel = "1.8.0" atspi = { version = "0.10.1", default-features = false } futures-lite = "1.12.0" -lazy_static = { version = "1.4.0", optional = true } +once_cell = { version = "1.17.1", optional = true } serde = "1.0" tokio = { version = "1.10.0", optional = true, features = ["rt-multi-thread", "net", "time"] } zbus = { version = "3.6", default-features = false } diff --git a/platforms/unix/src/util.rs b/platforms/unix/src/util.rs index 0cb1de9fc..a8a7fc16e 100644 --- a/platforms/unix/src/util.rs +++ b/platforms/unix/src/util.rs @@ -6,6 +6,8 @@ use crate::atspi::OwnedObjectAddress; use accesskit::{Point, Rect}; use atspi::CoordType; +#[cfg(feature = "tokio")] +use once_cell::sync::Lazy; #[cfg(not(feature = "tokio"))] pub(crate) fn block_on(future: F) -> F::Output { @@ -13,16 +15,14 @@ pub(crate) fn block_on(future: F) -> F::Output { } #[cfg(feature = "tokio")] -lazy_static::lazy_static! { - pub(crate) static ref TOKIO_RT: tokio::runtime::Runtime = { - tokio::runtime::Builder::new_multi_thread() - .worker_threads(1) - .enable_io() - .enable_time() - .build() - .expect("launch of single-threaded tokio runtime") - }; -} +pub(crate) static TOKIO_RT: Lazy = Lazy::new(|| { + tokio::runtime::Builder::new_multi_thread() + .worker_threads(1) + .enable_io() + .enable_time() + .build() + .expect("launch of single-threaded tokio runtime") +}); #[cfg(feature = "tokio")] pub(crate) fn block_on(future: F) -> F::Output { diff --git a/platforms/winit/Cargo.toml b/platforms/winit/Cargo.toml index dddab791c..2bea8226a 100644 --- a/platforms/winit/Cargo.toml +++ b/platforms/winit/Cargo.toml @@ -29,5 +29,4 @@ accesskit_macos = { version = "0.7.0", path = "../macos" } accesskit_unix = { version = "0.4.0", path = "../unix", optional = true, default-features = false } [dev-dependencies] -tokio = { version = "1", features = ["full"] } winit = "0.28"