Add Application::Executor associated type

This commit is contained in:
Héctor Ramón Jiménez 2020-01-20 04:47:36 +01:00
parent 35760ac68f
commit 90690702e1
29 changed files with 195 additions and 72 deletions

View file

@ -16,17 +16,11 @@ debug = []
[dependencies]
winit = { version = "0.20.0-alpha3", git = "https://github.com/hecrj/winit", rev = "709808eb4e69044705fcb214bcc30556db761405"}
log = "0.4"
futures = "0.3"
[dependencies.iced_native]
version = "0.1.0-alpha"
path = "../native"
[dependencies.iced_futures]
version = "0.1.0-alpha"
path = "../futures"
features = ["thread-pool"]
[dependencies.window_clipboard]
git = "https://github.com/hecrj/window_clipboard"
rev = "22c6dd6c04cd05d528029b50a30c56417cd4bebf"

View file

@ -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,14 +114,14 @@ pub trait Application: Sized {
debug.startup_started();
let event_loop = EventLoop::with_user_event();
let mut runtime = {
let thread_pool = futures::executor::ThreadPool::new()
.expect("Create thread pool");
Runtime::new(thread_pool, Proxy::new(event_loop.create_proxy()))
};
let mut external_messages = Vec::new();
let mut runtime = {
let executor = Self::Executor::new().expect("Create executor");
Runtime::new(executor, Proxy::new(event_loop.create_proxy()))
};
let (mut application, init_command) = Self::new();
runtime.spawn(init_command);

View file

@ -1,4 +1,4 @@
use futures::{
use iced_native::futures::{
task::{Context, Poll},
Sink,
};