1+ use core:: cell:: UnsafeCell ;
12use core:: ffi:: c_void;
23use core:: fmt;
4+ use core:: panic:: { RefUnwindSafe , UnwindSafe } ;
35use core:: ptr:: NonNull ;
4- use std:: cell:: UnsafeCell ;
5- use std:: panic:: { RefUnwindSafe , UnwindSafe } ;
6- use std:: sync:: atomic:: AtomicIsize ;
7- use std:: sync:: atomic:: Ordering ;
6+ use core:: sync:: atomic:: { AtomicIsize , Ordering } ;
87
98use crate :: ffi;
109
@@ -166,13 +165,13 @@ impl Once {
166165 invoke_dispatch_once ( predicate, work) ;
167166 }
168167
169- // NOTE: Unlike in C, we cannot use `std ::hint::assert_unchecked`,
168+ // NOTE: Unlike in C, we cannot use `core ::hint::assert_unchecked`,
170169 // since that would actually be lying from a language perspective;
171170 // the value seems to only settle on being !0 after some time
172171 // (something about the _COMM_PAGE_CPU_QUIESCENT_COUNTER?)
173172 //
174173 // TODO: Investigate this further!
175- // std ::hint::assert_unchecked(atomic_predicate.load(Ordering::Acquire) == !0);
174+ // core ::hint::assert_unchecked(atomic_predicate.load(Ordering::Acquire) == !0);
176175 } else {
177176 invoke_dispatch_once ( predicate, work) ;
178177 }
@@ -196,9 +195,8 @@ impl fmt::Debug for Once {
196195
197196#[ cfg( test) ]
198197mod tests {
199- use std:: cell:: Cell ;
200- use std:: mem:: ManuallyDrop ;
201- use std:: thread;
198+ use core:: cell:: Cell ;
199+ use core:: mem:: ManuallyDrop ;
202200
203201 use super :: * ;
204202
@@ -249,12 +247,13 @@ mod tests {
249247 }
250248
251249 #[ test]
250+ #[ cfg( feature = "std" ) ]
252251 fn test_threaded ( ) {
253252 let once = Once :: new ( ) ;
254253
255254 let num = AtomicIsize :: new ( 0 ) ;
256255
257- thread:: scope ( |scope| {
256+ std :: thread:: scope ( |scope| {
258257 scope. spawn ( || {
259258 once. call_once ( || {
260259 num. fetch_add ( 1 , Ordering :: Relaxed ) ;
@@ -329,9 +328,7 @@ mod tests {
329328 let once = Once :: new ( ) ;
330329
331330 once. call_once ( || {
332- once. call_once ( || {
333- println ! ( "foo" ) ;
334- } ) ;
331+ once. call_once ( || { } ) ;
335332 } ) ;
336333 }
337334}
0 commit comments