Skip to content

Commit 49e2317

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 1567429 commit 49e2317

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
@@ -66,6 +66,7 @@ reis = { version = "0.5", features = ["calloop"] }
6666
# CLI arguments
6767
clap_lex = "0.7"
6868
parking_lot = "0.12.3"
69+
futures-executor = { version = "0.3.31", features = ["thread-pool"] }
6970

7071
[dependencies.id_tree]
7172
branch = "feature/copy_clone"

src/state.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::{
3131
};
3232
use anyhow::Context;
3333
use calloop::RegistrationToken;
34+
use futures_executor::ThreadPool;
3435
use i18n_embed::{
3536
fluent::{fluent_language_loader, FluentLanguageLoader},
3637
DesktopLanguageRequester,
@@ -193,6 +194,7 @@ pub struct Common {
193194
pub display_handle: DisplayHandle,
194195
pub event_loop_handle: LoopHandle<'static, State>,
195196
pub event_loop_signal: LoopSignal,
197+
pub async_executor: ThreadPool,
196198

197199
pub popups: PopupManager,
198200
pub shell: Arc<parking_lot::RwLock<Shell>>,
@@ -606,6 +608,7 @@ impl State {
606608
display_handle: dh.clone(),
607609
event_loop_handle: handle,
608610
event_loop_signal: signal,
611+
async_executor: ThreadPool::builder().pool_size(1).create().unwrap(),
609612

610613
popups: PopupManager::default(),
611614
shell,

0 commit comments

Comments
 (0)