From bdca20fc4a3e8f6bd8ffb59de75e6ca0f8a94b6a Mon Sep 17 00:00:00 2001 From: Vladyslav Nikonov Date: Thu, 21 Oct 2021 22:42:14 +0300 Subject: Experimental wgpu WebGL backend support - Added missing `draw_cache_align_4x4` call for `brush_glyph` on wasm32 target - Added WebGL support to `integratio_wgpu` example - Fixed test.yml CI workflow - Removed spir-v shader in `integration_wgpu`; Fixed formatting - Removed redundant `BoxStream` typedef --- futures/src/runtime.rs | 49 +++++++++++++++++++++++++++++++--- futures/src/subscription/tracker.rs | 52 ++++++++++++++++++++++++++++++++----- 2 files changed, 92 insertions(+), 9 deletions(-) (limited to 'futures') diff --git a/futures/src/runtime.rs b/futures/src/runtime.rs index 7779e235..96104cd9 100644 --- a/futures/src/runtime.rs +++ b/futures/src/runtime.rs @@ -5,6 +5,50 @@ use crate::{subscription, Executor, Subscription}; use futures::{channel::mpsc, Sink}; use std::marker::PhantomData; +#[cfg(not(target_arch = "wasm32"))] +mod trait_aliases { + use super::*; + + pub trait RuntimeMessage: Send + 'static {} + + impl RuntimeMessage for T where T: Send + 'static {} + + pub trait RuntimeMessageSender: + Sink + Unpin + Send + Clone + 'static + { + } + + impl RuntimeMessageSender for T where + T: Sink + + Unpin + + Send + + Clone + + 'static + { + } +} + +#[cfg(target_arch = "wasm32")] +mod trait_aliases { + use super::*; + + pub trait RuntimeMessage: 'static {} + + impl RuntimeMessage for T where T: 'static {} + + pub trait RuntimeMessageSender: + Sink + Unpin + Clone + 'static + { + } + + impl RuntimeMessageSender for T where + T: Sink + Unpin + Clone + 'static + { + } +} + +pub use trait_aliases::{RuntimeMessage, RuntimeMessageSender}; + /// A batteries-included runtime of commands and subscriptions. /// /// If you have an [`Executor`], a [`Runtime`] can be leveraged to run any @@ -23,9 +67,8 @@ where Hasher: std::hash::Hasher + Default, Event: Send + Clone + 'static, Executor: self::Executor, - Sender: - Sink + Unpin + Send + Clone + 'static, - Message: Send + 'static, + Sender: RuntimeMessageSender, + Message: RuntimeMessage, { /// Creates a new empty [`Runtime`]. /// diff --git a/futures/src/subscription/tracker.rs b/futures/src/subscription/tracker.rs index 3a8d4a87..01e0c105 100644 --- a/futures/src/subscription/tracker.rs +++ b/futures/src/subscription/tracker.rs @@ -3,6 +3,50 @@ use crate::{BoxFuture, Subscription}; use futures::{channel::mpsc, sink::Sink}; use std::{collections::HashMap, marker::PhantomData}; +#[cfg(not(target_arch = "wasm32"))] +mod trait_aliases { + use super::*; + + pub trait TrackerMessage: Send + 'static {} + + impl TrackerMessage for T where T: Send + 'static {} + + pub trait TrackerMessageReceiver: + Sink + Unpin + Send + Clone + 'static + { + } + + impl TrackerMessageReceiver for T where + T: Sink + + Unpin + + Send + + Clone + + 'static + { + } +} + +#[cfg(target_arch = "wasm32")] +mod trait_aliases { + use super::*; + + pub trait TrackerMessage: 'static {} + + impl TrackerMessage for T where T: 'static {} + + pub trait TrackerMessageReceiver: + Sink + Unpin + Clone + 'static + { + } + + impl TrackerMessageReceiver for T where + T: Sink + Unpin + Clone + 'static + { + } +} + +pub use trait_aliases::{TrackerMessage, TrackerMessageReceiver}; + /// A registry of subscription streams. /// /// If you have an application that continuously returns a [`Subscription`], @@ -57,12 +101,8 @@ where receiver: Receiver, ) -> Vec> where - Message: 'static + Send, - Receiver: 'static - + Sink - + Unpin - + Send - + Clone, + Message: TrackerMessage, + Receiver: TrackerMessageReceiver, { use futures::{future::FutureExt, stream::StreamExt}; -- cgit