~thatonelutenist/actm

ff20c5f998a4f2717b0e39fce1db528d8a5258ac — Nathan McCarty 1 year, 9 months ago 45c7b6e
build: Feature gate async-std executor
M Cargo.toml => Cargo.toml +6 -1
@@ 10,9 10,14 @@ repository = "https://git.sr.ht/~thatonelutenist/peerdex"
license = "0BSD"
publish = false

[features]
# Support for the async-std executor
async-std = ["dep:async-std"]
default = ["async-std"]

[dependencies]
async-mutex = "1.4.0"
async-std = "1.12.0"
async-std = { version = "1.12.0", optional = true }
async-trait = "0.1.58"
enum_dispatch = "0.3.8"
flume = "0.10.14"

M src/executor.rs => src/executor.rs +2 -0
@@ 4,9 4,11 @@ use std::{convert::Infallible, future::Future};
use async_trait::async_trait;
use futures::future::BoxFuture;

#[cfg(feature = "async-std")]
pub mod asyncstd;
pub mod threads;

#[cfg(feature = "async-std")]
pub use asyncstd::AsyncStd;
pub use threads::Threads;


M src/testing_util.rs => src/testing_util.rs +1 -0
@@ 135,6 135,7 @@ mod tests {
    use super::*;
    use crate::traits::ActorExt;

    #[cfg(feature = "async-std")]
    mod async_math_actor {

        use futures::StreamExt;

M src/util/async_actor.rs => src/util/async_actor.rs +3 -2
@@ 402,7 402,7 @@ impl<X: Executor, I: Event, O: Event> Actor<I, O, X> for AsyncActor<I, O, X> {
mod tests {
    use super::*;
    use crate::{
        executor::{AsyncStd, Threads},
        executor::Threads,
        testing_util::{Add, Math, MathEvent, MathEventType, Output, OutputEvent},
        util::Collector,
    };


@@ 509,9 509,10 @@ mod tests {
        assert_eq!(collector_out, expected);
    }

    #[cfg(feature = "async-std")]
    #[async_std::test]
    async fn smoke_async_std() {
        smoke::<AsyncStd>().await;
        smoke::<crate::executor::AsyncStd>().await;
    }

    #[async_std::test]

M src/util/sync_actor.rs => src/util/sync_actor.rs +3 -2
@@ 375,7 375,7 @@ impl<X: Executor, I: Event, O: Event> Actor<I, O, X> for SyncActor<I, O, X> {
mod tests {
    use super::*;
    use crate::{
        executor::{AsyncStd, Threads},
        executor::Threads,
        testing_util::{Add, Math, MathEvent, MathEventType, Output, OutputEvent},
        util::Collector,
    };


@@ 471,9 471,10 @@ mod tests {
        assert_eq!(collector_out, expected);
    }

    #[cfg(feature = "async-std")]
    #[test]
    fn smoke_async_std() {
        smoke::<AsyncStd>();
        smoke::<crate::executor::AsyncStd>();
    }

    #[test]

M src/util/wrapped_channels.rs => src/util/wrapped_channels.rs +3 -2
@@ 137,7 137,7 @@ mod tests {

    use super::*;
    use crate::{
        executor::{AsyncStd, Executor, Threads},
        executor::{Executor, Threads},
        traits::Actor,
        util::{AsyncActor, WrappedEvent},
    };


@@ 203,9 203,10 @@ mod tests {
        assert!(res.val == 99 || res.val == 100);
    }

    #[cfg(feature = "async-std")]
    #[async_std::test]
    async fn smoke_async_std() {
        smoke::<AsyncStd>().await;
        smoke::<crate::executor::AsyncStd>().await;
    }

    #[async_std::test]