From 6531bd6c5e993c0dbb286089f6aec3063810ae44 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 16 Mar 2022 11:13:37 -0700 Subject: [PATCH 1/2] chore(ci): add Windows and macOS test jobs to CI (#53) Signed-off-by: Eliza Weisman --- .github/workflows/tests.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3ff8f33..9293f55 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,13 +23,18 @@ jobs: tests: name: Tests - runs-on: ubuntu-latest strategy: matrix: - rust: - - stable - - nightly - - 1.57.0 + # test all Rust versions on Ubuntu + rust: [stable, 1.57.0] + os: [ubuntu-latest, m] + # test stable Rust on Windows and MacOS as well + include: + - rust: stable + os: windows-latest + - rust: stable + os: macos-latest + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Install toolchain From 91709ecc3e049623c945132cafed2828b8868eb0 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 16 Mar 2022 11:17:43 -0700 Subject: [PATCH 2/2] fix(mpsc): compilation error on macOS (#53) This fixes a compilation error that occurs on macOS due to `std::thread::Thread` not being `UnwindSafe` on that platform. It's kind of sad that we have to do this, but I think it's probably fine. Fixes #54 Signed-off-by: Eliza Weisman --- src/wait.rs | 3 +-- src/wait/cell.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/wait.rs b/src/wait.rs index f19b064..e154f99 100644 --- a/src/wait.rs +++ b/src/wait.rs @@ -19,7 +19,6 @@ //! [`core::task::Waker`]s, for the async MPSC, or [`std::thread::Thread`]s, for //! the blocking MPSC. In either case, the role played by these types is fairly //! analogous. -use crate::util::panic::UnwindSafe; use core::{fmt, task::Waker}; mod cell; @@ -54,7 +53,7 @@ pub(crate) enum WaitResult { Notified, } -pub(crate) trait Notify: UnwindSafe + fmt::Debug + Clone { +pub(crate) trait Notify: fmt::Debug + Clone { fn notify(self); fn same(&self, other: &Self) -> bool; diff --git a/src/wait/cell.rs b/src/wait/cell.rs index 53ba117..e01d4dc 100644 --- a/src/wait/cell.rs +++ b/src/wait/cell.rs @@ -99,7 +99,10 @@ impl WaitCell { let result = match test_dbg!(self.compare_exchange(State::PARKING, State::WAITING, AcqRel)) { Ok(_) => { - let _ = panic::catch_unwind(move || drop(prev_waiter)); + // XXX(eliza): it's kind of sad we have to use + // `AssertUnwindSafe` here, because `std::thread::Thread` + // contains a `Condvar` on macOS :( + let _ = panic::catch_unwind(panic::AssertUnwindSafe(move || drop(prev_waiter))); WaitResult::Wait } @@ -117,9 +120,11 @@ impl WaitCell { ); if let Some(prev_waiter) = prev_waiter { - let _ = panic::catch_unwind(move || { + // XXX(eliza): similarly, it's necessary to assert unwind + // safety due to `std::thread::Thread` on macOS here... + let _ = panic::catch_unwind(panic::AssertUnwindSafe(move || { prev_waiter.notify(); - }); + })); } if let Some(waiter) = waiter {