feat: Mark StackSlot as Sync

Since it has no interior mutability it should be safe to share between
threads.

Signed-off-by: John Nunley <dev@notgull.net>
This commit is contained in:
John Nunley 2024-02-25 18:02:44 -08:00 committed by GitHub
parent 3a49a00639
commit c9d736a29b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -67,7 +67,7 @@
//!
//! [`portable-atomic`]: https://crates.io/crates/portable-atomic
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![doc(
html_favicon_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png"
@ -76,7 +76,10 @@
html_logo_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png"
)]
#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std as alloc;
#[cfg_attr(feature = "std", path = "std.rs")]
#[cfg_attr(not(feature = "std"), path = "no_std.rs")]
@ -84,6 +87,7 @@ mod sys;
mod notify;
#[cfg(not(feature = "std"))]
use alloc::boxed::Box;
use core::borrow::Borrow;
@ -1365,6 +1369,9 @@ fn __test_send_and_sync() {
fn _assert_sync<T: Sync>() {}
_assert_send::<crate::__private::StackSlot<'_, ()>>();
_assert_sync::<crate::__private::StackSlot<'_, ()>>();
_assert_send::<crate::__private::StackListener<'_, '_, ()>>();
_assert_sync::<crate::__private::StackListener<'_, '_, ()>>();
_assert_send::<Event<()>>();
_assert_sync::<Event<()>>();
_assert_send::<EventListener<()>>();
@ -1410,6 +1417,7 @@ pub mod __private {
impl<T> core::panic::UnwindSafe for StackSlot<'_, T> {}
impl<T> core::panic::RefUnwindSafe for StackSlot<'_, T> {}
unsafe impl<T> Send for StackSlot<'_, T> {}
unsafe impl<T> Sync for StackSlot<'_, T> {}
impl<'ev, T> StackSlot<'ev, T> {
/// Create a new `StackSlot` on the stack.

View File

@ -832,7 +832,6 @@ unsafe impl<T: Send> Sync for Mutex<T> {}
#[cfg(test)]
mod tests {
use super::*;
use crate::Task;
#[cfg(target_family = "wasm")]
use wasm_bindgen_test::wasm_bindgen_test as test;