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

fix(mpsc): compilation error on macOS #53

Merged
merged 4 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 8 additions & 3 deletions src/wait/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ impl<T: Notify> WaitCell<T> {
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)));
hawkw marked this conversation as resolved.
Show resolved Hide resolved

WaitResult::Wait
}
Expand All @@ -117,9 +120,11 @@ impl<T: Notify> WaitCell<T> {
);

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 {
Expand Down