diff options
author | 2020-01-20 04:47:36 +0100 | |
---|---|---|
committer | 2020-01-20 04:47:36 +0100 | |
commit | 90690702e1e4abab804ec91e8ff4183824bec436 (patch) | |
tree | d3f989047f4ac5166bc5baed9febcc10af2d63a6 /winit/src | |
parent | 35760ac68f06e783e64e9048aff0fff6df1c09cf (diff) | |
download | iced-90690702e1e4abab804ec91e8ff4183824bec436.tar.gz iced-90690702e1e4abab804ec91e8ff4183824bec436.tar.bz2 iced-90690702e1e4abab804ec91e8ff4183824bec436.zip |
Add `Application::Executor` associated type
Diffstat (limited to 'winit/src')
-rw-r--r-- | winit/src/application.rs | 18 | ||||
-rw-r--r-- | winit/src/proxy.rs | 2 |
2 files changed, 12 insertions, 8 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index 076ac092..4b21a930 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -1,10 +1,9 @@ use crate::{ conversion, input::{keyboard, mouse}, - window, Cache, Clipboard, Command, Debug, Element, Event, Mode, - MouseCursor, Proxy, Settings, Size, Subscription, UserInterface, + window, Cache, Clipboard, Command, Debug, Element, Event, Executor, Mode, + MouseCursor, Proxy, Runtime, Settings, Size, Subscription, UserInterface, }; -use iced_native::Runtime; /// An interactive, native cross-platform application. /// @@ -20,6 +19,11 @@ pub trait Application: Sized { /// [`Application`]: trait.Application.html type Renderer: window::Renderer; + /// The [`Executor`] that will run commands and subscriptions. + /// + /// [`Executor`]: trait.Executor.html + type Executor: Executor; + /// The type of __messages__ your [`Application`] will produce. /// /// [`Application`]: trait.Application.html @@ -110,13 +114,13 @@ pub trait Application: Sized { debug.startup_started(); let event_loop = EventLoop::with_user_event(); + let mut external_messages = Vec::new(); + let mut runtime = { - let thread_pool = futures::executor::ThreadPool::new() - .expect("Create thread pool"); + let executor = Self::Executor::new().expect("Create executor"); - Runtime::new(thread_pool, Proxy::new(event_loop.create_proxy())) + Runtime::new(executor, Proxy::new(event_loop.create_proxy())) }; - let mut external_messages = Vec::new(); let (mut application, init_command) = Self::new(); runtime.spawn(init_command); diff --git a/winit/src/proxy.rs b/winit/src/proxy.rs index 7e8dee98..cff9df33 100644 --- a/winit/src/proxy.rs +++ b/winit/src/proxy.rs @@ -1,4 +1,4 @@ -use futures::{ +use iced_native::futures::{ task::{Context, Poll}, Sink, }; |