feat(executor): add cosmic::executor::Default
This commit is contained in:
parent
a1b3d6ec38
commit
cc21b9baa1
4 changed files with 13 additions and 7 deletions
|
|
@ -302,7 +302,7 @@ impl Window {
|
|||
}
|
||||
|
||||
impl Application for Window {
|
||||
type Executor = iced::executor::Default;
|
||||
type Executor = cosmic::executor::Default;
|
||||
type Flags = ();
|
||||
type Message = Message;
|
||||
type Theme = Theme;
|
||||
|
|
|
|||
7
src/executor/mod.rs
Normal file
7
src/executor/mod.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
pub mod single;
|
||||
|
||||
#[cfg(not(feature = "tokio"))]
|
||||
pub type Default = iced::executor::Default;
|
||||
|
||||
#[cfg(feature = "tokio")]
|
||||
pub type Default = single::Executor;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
use std::{future::Future, thread};
|
||||
use std::future::Future;
|
||||
|
||||
#[cfg(feature = "tokio")]
|
||||
pub struct SingleThreadExecutor(tokio::runtime::Runtime);
|
||||
pub struct Executor(tokio::runtime::Runtime);
|
||||
|
||||
#[cfg(feature = "tokio")]
|
||||
impl iced_native::Executor for SingleThreadExecutor {
|
||||
impl iced_native::Executor for Executor {
|
||||
fn new() -> Result<Self, iced::futures::io::Error> {
|
||||
// Current thread executor requires calling `block_on` to actually run
|
||||
// futures. Main thread is busy with things other than running futures,
|
||||
|
|
@ -14,15 +14,14 @@ pub use iced_winit;
|
|||
|
||||
#[cfg(feature = "applet")]
|
||||
pub mod applet;
|
||||
pub mod executor;
|
||||
pub mod font;
|
||||
pub mod keyboard_nav;
|
||||
pub mod theme;
|
||||
pub mod widget;
|
||||
|
||||
#[cfg(feature = "tokio")]
|
||||
mod single_thread_executor;
|
||||
#[cfg(feature = "tokio")]
|
||||
pub use single_thread_executor::SingleThreadExecutor;
|
||||
pub use executor::single::Executor as SingleThreadExecutor;
|
||||
|
||||
pub mod settings;
|
||||
pub use settings::settings;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue