Skip to content

Commit d0b37f7

Browse files
committed
trim out all of the not immediatelly necessary bits of futures-time
* don't need streams yet - they arent connected to wasi streams * don't need channels * don't need park * don't need relative future We can add all of these back in later once we are ready.
1 parent cec4f6a commit d0b37f7

26 files changed

+3
-1367
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ authors = [
1515
[features]
1616

1717
[dependencies]
18-
async-channel.workspace = true
1918
futures-core.workspace = true
2019
http.workspace = true
2120
pin-project-lite.workspace = true
@@ -48,7 +47,6 @@ repository = "https://github.com/yoshuawuyts/wstd"
4847

4948
[workspace.dependencies]
5049
anyhow = "1"
51-
async-channel = "1.6.1"
5250
cargo_metadata = "0.18.1"
5351
futures-core = "0.3.19"
5452
futures-lite = "1.12.0"

src/future/future_ext.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
use core::future::Future;
2-
3-
use crate::channel::Parker;
4-
use crate::stream::IntoStream;
5-
6-
use super::{Delay, IntoFuture, Park, Timeout};
1+
use super::{Delay, Timeout};
2+
use std::future::{Future, IntoFuture};
73

84
/// Extend `Future` with time-based operations.
95
pub trait FutureExt: Future {
@@ -75,19 +71,6 @@ pub trait FutureExt: Future {
7571
{
7672
Delay::new(self, deadline.into_future())
7773
}
78-
/// Suspend or resume execution of a future.
79-
///
80-
/// When this method is called the execution of the future will be put into
81-
/// a suspended state until the channel returns `Parker::Unpark` or the
82-
/// channel's senders are dropped. The underlying future will not be polled
83-
/// while the it is paused.
84-
fn park<I>(self, interval: I) -> Park<Self, I::IntoStream>
85-
where
86-
Self: Sized,
87-
I: IntoStream<Item = Parker>,
88-
{
89-
Park::new(self, interval.into_stream())
90-
}
9174
}
9275

9376
impl<T> FutureExt for T where T: Future {}

src/future/mod.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,18 @@
88
//! like with `?` we have to be careful to roll back local state if our future
99
//! halts there.
1010
//!
11-
//! In order to perform a cancellation remotely, you can use the [`channel::bounded`]
12-
//! function to create a sender/receiver pair. When the sender side of
13-
//! this pair emits a message, all receivers are trigered. Receivers can be passed to
14-
//! [`Future::timeout`] or [`Stream::timeout`] to perform a cancellation when
15-
//! the message is received.
16-
//!
17-
//! [`channel::bounded`]: crate::channel::bounded
18-
//! [`Future::timeout`]: crate::future::FutureExt::timeout
19-
//! [`Stream::timeout`]: crate::stream::StreamExt::timeout
20-
//!
2111
//!
2212
//! ```no_run
2313
//! use futures_lite::prelude::*;
2414
//! use wstd::prelude::*;
25-
//! use wstd::channel;
2615
//! use wstd::time::Duration;
2716
//!
2817
//! #[wstd::main]
2918
//! async fn main() {
30-
//! let (send, mut recv) = channel::bounded::<()>(1); // create a new send/receive pair
3119
//! let mut counter = 0;
3220
//! let value = async { "meow" }
3321
//! .delay(Duration::from_millis(100))
34-
//! .timeout(recv.next()) // time-out if the sender is dropped.
22+
//! .timeout(Duration::from_millis(200))
3523
//! .await;
3624
//!
3725
//! assert_eq!(value.unwrap(), "meow");
@@ -40,13 +28,8 @@
4028
4129
mod delay;
4230
mod future_ext;
43-
mod park;
44-
mod relative_future;
4531
mod timeout;
4632

4733
pub use delay::Delay;
4834
pub use future_ext::FutureExt;
49-
pub use park::Park;
50-
pub use relative_future::Timer;
51-
pub use std::future::IntoFuture;
5235
pub use timeout::Timeout;

src/future/park.rs

Lines changed: 0 additions & 95 deletions
This file was deleted.

src/future/relative_future.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/lib.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,14 @@ pub mod iter;
5555
pub mod net;
5656
pub mod rand;
5757
pub mod runtime;
58-
pub mod stream;
5958
pub mod task;
6059
pub mod time;
6160

6261
pub use wstd_macro::attr_macro_main as main;
6362

6463
pub mod prelude {
6564
pub use crate::future::FutureExt as _;
66-
pub use crate::future::Timer as _;
6765
pub use crate::http::Body as _;
6866
pub use crate::io::AsyncRead as _;
6967
pub use crate::io::AsyncWrite as _;
70-
pub use crate::stream::IntoStream as _;
71-
pub use crate::stream::StreamExt as _;
72-
pub use std::future::IntoFuture as _;
73-
}
74-
75-
/// An async multi-producer multi-consumer channel.
76-
pub mod channel {
77-
/// Suspend or resume execution of a future.
78-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
79-
pub enum Parker {
80-
/// Put the future into a suspended state.
81-
Park,
82-
/// Put the future into an active state.
83-
Unpark,
84-
}
85-
#[doc(inline)]
86-
pub use async_channel::*;
8768
}

src/stream/buffer.rs

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)