Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task API #2463

Merged
merged 11 commits into from
Jun 16, 2024
Prev Previous commit
Next Next commit
Move Maybe* traits back to iced_futures
  • Loading branch information
hecrj committed Jun 13, 2024
commit 4e7cbbf98ab745351e2fb13a7c85d4ad560c21ee
2 changes: 0 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ mod color;
mod content_fit;
mod element;
mod length;
mod maybe;
mod padding;
mod pixels;
mod point;
Expand All @@ -60,7 +59,6 @@ pub use font::Font;
pub use gradient::Gradient;
pub use layout::Layout;
pub use length::Length;
pub use maybe::{MaybeSend, MaybeSync};
pub use overlay::Overlay;
pub use padding::Padding;
pub use pixels::Pixels;
Expand Down
2 changes: 1 addition & 1 deletion futures/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Listen to runtime events.
use crate::core::event::{self, Event};
use crate::core::window;
use crate::core::MaybeSend;
use crate::subscription::{self, Subscription};
use crate::MaybeSend;

/// Returns a [`Subscription`] to all the ignored runtime events.
///
Expand Down
3 changes: 2 additions & 1 deletion futures/src/executor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Choose your preferred executor to power a runtime.
use crate::core::MaybeSend;
use crate::MaybeSend;

use futures::Future;

/// A type that can run futures.
Expand Down
2 changes: 1 addition & 1 deletion futures/src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
use crate::core;
use crate::core::event;
use crate::core::keyboard::{Event, Key, Modifiers};
use crate::core::MaybeSend;
use crate::subscription::{self, Subscription};
use crate::MaybeSend;

/// Listens to keyboard key presses and calls the given function
/// map them into actual messages.
Expand Down
2 changes: 2 additions & 0 deletions futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
pub use futures;
pub use iced_core as core;

mod maybe;
mod runtime;

pub mod backend;
Expand All @@ -17,6 +18,7 @@ pub mod keyboard;
pub mod subscription;

pub use executor::Executor;
pub use maybe::{MaybeSend, MaybeSync};
pub use platform::*;
pub use runtime::Runtime;
pub use subscription::Subscription;
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions futures/src/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Run commands and keep track of subscriptions.
use crate::core::MaybeSend;
use crate::subscription;
use crate::{BoxFuture, BoxStream, Executor};
use crate::{BoxFuture, BoxStream, Executor, MaybeSend};

use futures::{channel::mpsc, Sink};
use std::marker::PhantomData;
Expand Down
3 changes: 1 addition & 2 deletions futures/src/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ pub use tracker::Tracker;

use crate::core::event;
use crate::core::window;
use crate::core::MaybeSend;
use crate::futures::{Future, Stream};
use crate::BoxStream;
use crate::{BoxStream, MaybeSend};

use futures::channel::mpsc;
use futures::never::Never;
Expand Down
3 changes: 1 addition & 2 deletions futures/src/subscription/tracker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::core::MaybeSend;
use crate::subscription::{Event, Hasher, Recipe};
use crate::BoxFuture;
use crate::{BoxFuture, MaybeSend};

use futures::channel::mpsc;
use futures::sink::{Sink, SinkExt};
Expand Down
3 changes: 2 additions & 1 deletion graphics/src/compositor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! A compositor is responsible for initializing a renderer and managing window
//! surfaces.
use crate::core::{Color, MaybeSend, MaybeSync};
use crate::core::Color;
use crate::futures::{MaybeSend, MaybeSync};
use crate::{Error, Settings, Viewport};

use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
Expand Down
3 changes: 1 addition & 2 deletions runtime/src/task.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::core::widget;
use crate::core::MaybeSend;
use crate::futures::futures::channel::mpsc;
use crate::futures::futures::channel::oneshot;
use crate::futures::futures::future::{self, FutureExt};
use crate::futures::futures::never::Never;
use crate::futures::futures::stream::{self, Stream, StreamExt};
use crate::futures::{boxed_stream, BoxStream};
use crate::futures::{boxed_stream, BoxStream, MaybeSend};
use crate::Action;

use std::future::Future;
Expand Down Expand Up @@ -75,7 +74,7 @@
let action = f(sender);

Self(Some(boxed_stream(
stream::once(async move { action }).chain(

Check failure on line 77 in runtime/src/task.rs

View workflow job for this annotation

GitHub Actions / all (windows-latest, stable)

future cannot be sent between threads safely

Check failure on line 77 in runtime/src/task.rs

View workflow job for this annotation

GitHub Actions / all (windows-latest, stable)

future cannot be sent between threads safely
receiver.into_stream().filter_map(|result| async move {
Some(Action::Output(result.ok()?))
}),
Expand All @@ -94,7 +93,7 @@
let action = f(sender);

Self(Some(boxed_stream(
stream::once(async move { action })

Check failure on line 96 in runtime/src/task.rs

View workflow job for this annotation

GitHub Actions / all (windows-latest, stable)

future cannot be sent between threads safely

Check failure on line 96 in runtime/src/task.rs

View workflow job for this annotation

GitHub Actions / all (windows-latest, stable)

future cannot be sent between threads safely
.chain(receiver.map(|result| Action::Output(result))),
)))
}
Expand All @@ -103,7 +102,7 @@
pub fn effect(action: impl Into<Action<Never>>) -> Self {
let action = action.into();

Self(Some(boxed_stream(stream::once(async move {

Check failure on line 105 in runtime/src/task.rs

View workflow job for this annotation

GitHub Actions / all (windows-latest, stable)

future cannot be sent between threads safely

Check failure on line 105 in runtime/src/task.rs

View workflow job for this annotation

GitHub Actions / all (windows-latest, stable)

future cannot be sent between threads safely
action.output().expect_err("no output")
}))))
}
Expand Down Expand Up @@ -140,7 +139,7 @@
match action.output() {
Ok(output) => f(output)
.0
.unwrap_or_else(|| boxed_stream(stream::empty())),

Check failure on line 142 in runtime/src/task.rs

View workflow job for this annotation

GitHub Actions / all (windows-latest, stable)

`NonNull<c_void>` cannot be sent between threads safely

Check failure on line 142 in runtime/src/task.rs

View workflow job for this annotation

GitHub Actions / all (windows-latest, stable)

`NonNull<c_void>` cannot be sent between threads safely
Err(action) => {
boxed_stream(stream::once(async move { action }))
}
Expand Down
Loading