Skip to content

Commit 42edf6a

Browse files
committed
Add a ThreadPool async executor to State
If we need to use simple async code in a few places, a single executor may be better than having several threads blocking on async code. This should probably use the calloop executor, but that's had issues in cosmic-workspaces, though that may not apply here.
1 parent 3465ce7 commit 42edf6a

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ reis = { version = "0.5", features = ["calloop"] }
8989
clap_lex = "0.7"
9090
parking_lot = "0.12.4"
9191
logind-zbus = { version = "5.3.2", optional = true }
92+
futures-executor = { version = "0.3.31", features = ["thread-pool"] }
9293

9394
[dependencies.id_tree]
9495
branch = "feature/copy_clone"

src/state.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use crate::{
3333
use anyhow::Context;
3434
use calloop::RegistrationToken;
3535
use cosmic_comp_config::output::comp::{OutputConfig, OutputState};
36+
use futures_executor::ThreadPool;
3637
use i18n_embed::{
3738
fluent::{fluent_language_loader, FluentLanguageLoader},
3839
DesktopLanguageRequester,
@@ -198,6 +199,7 @@ pub struct Common {
198199
pub display_handle: DisplayHandle,
199200
pub event_loop_handle: LoopHandle<'static, State>,
200201
pub event_loop_signal: LoopSignal,
202+
pub async_executor: ThreadPool,
201203

202204
pub popups: PopupManager,
203205
pub shell: Arc<parking_lot::RwLock<Shell>>,
@@ -697,6 +699,7 @@ impl State {
697699
display_handle: dh.clone(),
698700
event_loop_handle: handle,
699701
event_loop_signal: signal,
702+
async_executor: ThreadPool::builder().pool_size(1).create().unwrap(),
700703

701704
popups: PopupManager::default(),
702705
shell,

0 commit comments

Comments
 (0)