@@ -65,7 +65,6 @@ mod task_queue {
6565/// execution. The signal is sent once all TLS destructors have finished at
6666/// which point no new thread locals should be created.
6767pub mod wait_notify {
68- use crate :: mem:: MaybeUninit ;
6968 use crate :: pin:: Pin ;
7069 use crate :: sync:: Arc ;
7170 use crate :: sys_common:: thread_parking:: Parker ;
@@ -88,25 +87,14 @@ pub mod wait_notify {
8887 /// called, this will return immediately, otherwise the current thread
8988 /// is blocked until notified.
9089 pub fn wait ( self ) {
91- // This is not actually `unsafe`, but it uses the `Parker` API,
92- // which needs `unsafe` on some platforms .
90+ // SAFETY:
91+ // This is only ever called on one thread .
9392 unsafe { Pin :: new ( & * self . 0 ) . park ( ) }
9493 }
9594 }
9695
9796 pub fn new ( ) -> ( Notifier , Waiter ) {
98- // Safety:
99- // Some other platforms (looking at you, UNIX!) require that the thread
100- // parker is constructed in-place. This is just a noisy way of writing:
101- // ```rust
102- // let parker = Parker::new();
103- // ```
104- let parker = unsafe {
105- let mut place = MaybeUninit :: uninit ( ) ;
106- Parker :: new ( place. as_mut_ptr ( ) ) ;
107- place. assume_init ( )
108- } ;
109- let inner = Arc :: new ( parker) ;
97+ let inner = Arc :: new ( Parker :: new ( ) ) ;
11098 ( Notifier ( inner. clone ( ) ) , Waiter ( inner) )
11199 }
112100}
0 commit comments