Skip to content

Commit

Permalink
Fix async-std and re-enable Ci for async-std builds
Browse files Browse the repository at this point in the history
  • Loading branch information
slawlor committed Jan 23, 2025
1 parent a4f92a8 commit 02e37ea
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 14 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,27 @@ jobs:
- name: Run the default tests
package: ractor
# flags:
- name: Test ractor without async-trait
- name: Test ractor with async-trait
package: ractor
flags: --no-default-features -F tokio_runtime,message_span_propogation
flags: -F async-trait
- name: Test ractor without span propogation
package: ractor
flags: --no-default-features -F tokio_runtime,async-trait
flags: --no-default-features -F tokio_runtime
- name: Test ractor with the `cluster` feature
package: ractor
flags: -F cluster
- name: Test ractor with the `blanket_serde` feature
package: ractor
flags: -F blanket_serde
- name: Test ractor with async-std runtime
package: ractor
flags: --no-default-features -F async-std,message_span_propogation
- name: Test ractor with async-std runtime but no span propagation
package: ractor
flags: --no-default-features -F async-std
- name: Test ractor with async-std runtime and async-trait
package: ractor
flags: --no-default-features -F async-std,async-trait
- name: Test ractor_cluster with native async traits
package: ractor_cluster
# flags:
Expand Down
2 changes: 1 addition & 1 deletion ractor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ractor"
version = "0.14.6"
version = "0.14.7"
authors = ["Sean Lawlor", "Evan Au", "Dillon George"]
description = "A actor framework for Rust"
documentation = "https://docs.rs/ractor"
Expand Down
36 changes: 28 additions & 8 deletions ractor/src/actor/supervision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,20 @@ impl SupervisionTree {
}
// drain the tasks
while let Some(res) = js.join_next().await {
match res {
Err(err) if err.is_panic() => std::panic::resume_unwind(err.into_panic()),
Err(err) => panic!("{err}"),
_ => {}
#[cfg(feature = "async-std")]
{
match res {
Err(_) => panic!("JoinSet join error"),
_ => {}
}
}
#[cfg(not(feature = "async-std"))]
{
match res {
Err(err) if err.is_panic() => std::panic::resume_unwind(err.into_panic()),
Err(err) => panic!("{err}"),

Check warning on line 148 in ractor/src/actor/supervision.rs

View check run for this annotation

Codecov / codecov/patch

ractor/src/actor/supervision.rs#L146-L148

Added lines #L146 - L148 were not covered by tests
_ => {}
}
}
}
}
Expand All @@ -155,10 +165,20 @@ impl SupervisionTree {
}
// drain the tasks
while let Some(res) = js.join_next().await {
match res {
Err(err) if err.is_panic() => std::panic::resume_unwind(err.into_panic()),
Err(err) => panic!("{err}"),
_ => {}
#[cfg(feature = "async-std")]
{
match res {
Err(_) => panic!("JoinSet join error"),
_ => {}
}
}
#[cfg(not(feature = "async-std"))]
{
match res {
Err(err) if err.is_panic() => std::panic::resume_unwind(err.into_panic()),
Err(err) => panic!("{err}"),

Check warning on line 179 in ractor/src/actor/supervision.rs

View check run for this annotation

Codecov / codecov/patch

ractor/src/actor/supervision.rs#L177-L179

Added lines #L177 - L179 were not covered by tests
_ => {}
}
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions ractor/src/concurrency/async_std_primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//! such as channels (see: https://github.com/tokio-rs/tokio/issues/4232#issuecomment-968329443).
use std::{
fmt::Debug,
future::Future,
pin::Pin,
sync::{
Expand All @@ -28,6 +29,16 @@ pub struct JoinHandle<T> {
handle: Option<async_std::task::JoinHandle<T>>,
is_done: Arc<AtomicBool>,
}

impl<T> Debug for JoinHandle<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("JoinHandle")
.field("name", &self.is_done.load(Ordering::Relaxed))
.field("handle", &self.handle.is_some())
.finish()
}
}

impl<T> JoinHandle<T> {
/// Determine if the handle is currently finished
pub fn is_finished(&self) -> bool {
Expand Down Expand Up @@ -74,6 +85,7 @@ pub type Instant = std::time::Instant;
/// An asynchronous interval calculation which waits until
/// a checkpoint time to tick. This is a replication of the
/// basic functionality from `tokio`'s `Interval`.
#[derive(Debug, Clone)]
pub struct Interval {
dur: Duration,
next_tick: Instant,
Expand Down Expand Up @@ -110,6 +122,14 @@ pub struct JoinSet<T> {
set: FuturesUnordered<BoxFuture<'static, T>>,
}

impl<T> Debug for JoinSet<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("JoinSet")
.field("size", &self.set.len())
.finish()
}
}

impl<T> JoinSet<T> {
/// Creates a new [JoinSet]
pub fn new() -> JoinSet<T> {
Expand Down
2 changes: 1 addition & 1 deletion ractor_cluster/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ractor_cluster"
version = "0.14.6"
version = "0.14.7"
authors = ["Sean Lawlor <slawlor>"]
description = "Distributed cluster environment of Ractor actors"
documentation = "https://docs.rs/ractor"
Expand Down
2 changes: 1 addition & 1 deletion ractor_cluster_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ractor_cluster_derive"
version = "0.14.6"
version = "0.14.7"
authors = ["Sean Lawlor <slawlor>"]
description = "Derives for ractor_cluster"
license = "MIT"
Expand Down

0 comments on commit 02e37ea

Please sign in to comment.