Skip to content

Commit cf61e47

Browse files
authored
fix: Don't require tokio rt-multi-thread feature (#290)
1 parent 4fc9c55 commit cf61e47

File tree

3 files changed

+19
-28
lines changed

3 files changed

+19
-28
lines changed

Cargo.lock

Lines changed: 1 addition & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platforms/unix/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ atspi = { version = "0.10.1", default-features = false }
2323
futures-lite = "1.12.0"
2424
once_cell = { version = "1.17.1", optional = true }
2525
serde = "1.0"
26-
tokio = { version = "1.10.0", optional = true, features = ["rt-multi-thread", "net", "time"] }
26+
tokio = { version = "1.10.0", optional = true, features = ["rt", "net", "time"] }
2727
zbus = { version = "3.6", default-features = false }
2828

platforms/unix/src/util.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,24 @@ pub(crate) fn block_on<F: std::future::Future>(future: F) -> F::Output {
1515
}
1616

1717
#[cfg(feature = "tokio")]
18-
pub(crate) static TOKIO_RT: Lazy<tokio::runtime::Runtime> = Lazy::new(|| {
19-
tokio::runtime::Builder::new_multi_thread()
20-
.worker_threads(1)
21-
.enable_io()
22-
.enable_time()
18+
pub(crate) static TOKIO_RT: Lazy<tokio::runtime::Handle> = Lazy::new(|| {
19+
let rt = tokio::runtime::Builder::new_current_thread()
20+
.enable_all()
2321
.build()
24-
.expect("launch of single-threaded tokio runtime")
22+
.expect("create tokio runtime");
23+
let handle = rt.handle().clone();
24+
std::thread::Builder::new()
25+
.name("accesskit-tokio".into())
26+
.spawn(move || {
27+
rt.block_on(async {
28+
let duration = std::time::Duration::from_secs(86400);
29+
loop {
30+
tokio::time::sleep(duration).await;
31+
}
32+
});
33+
})
34+
.expect("launch tokio runtime thread");
35+
handle
2536
});
2637

2738
#[cfg(feature = "tokio")]

0 commit comments

Comments
 (0)