Skip to content

Commit 6587461

Browse files
committed
Make sure Event/EventListener are Send/Sync (#59)
Necessary to resolve failing tests in smol-rs/async-channel#59
1 parent 42d2dc7 commit 6587461

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ impl<T> Drop for Event<T> {
639639
/// kind of notification was delivered.
640640
pub struct EventListener<T = ()>(Listener<T, Arc<Inner<T>>>);
641641

642+
unsafe impl<T: Send> Send for EventListener<T> {}
643+
unsafe impl<T: Send> Sync for EventListener<T> {}
644+
642645
impl<T> fmt::Debug for EventListener<T> {
643646
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
644647
f.write_str("EventListener { .. }")
@@ -1132,3 +1135,13 @@ mod sync {
11321135
}
11331136
}
11341137
}
1138+
1139+
fn __test_send_and_sync() {
1140+
fn _assert_send<T: Send>() {}
1141+
fn _assert_sync<T: Sync>() {}
1142+
1143+
_assert_send::<Event<()>>();
1144+
_assert_sync::<Event<()>>();
1145+
_assert_send::<EventListener<()>>();
1146+
_assert_sync::<EventListener<()>>();
1147+
}

0 commit comments

Comments
 (0)