@@ -355,25 +355,16 @@ impl Once {
355355 // performance difference really does not matter there, and
356356 // SeqCst minimizes the chances of something going wrong.
357357 let mut state_and_queue = self . state_and_queue . load ( Ordering :: SeqCst ) ;
358-
359358 loop {
360359 match state_and_queue {
361- // If we're complete, then there's nothing to do, we just
362- // jettison out as we shouldn't run the closure.
363- COMPLETE => return ,
364-
365- // If we're poisoned and we're not in a mode to ignore
366- // poisoning, then we panic here to propagate the poison.
360+ COMPLETE => break ,
367361 POISONED if !ignore_poisoning => {
362+ // Panic to propagate the poison.
368363 panic ! ( "Once instance has previously been poisoned" ) ;
369364 }
370-
371- // Otherwise if we see a poisoned or otherwise incomplete state
372- // we will attempt to move ourselves into the RUNNING state. If
373- // we succeed, then the queue of waiters starts at null (all 0
374- // bits).
375365 POISONED |
376366 INCOMPLETE => {
367+ // Try to register this thread as the one RUNNING.
377368 let old = self . state_and_queue . compare_and_swap ( state_and_queue,
378369 RUNNING ,
379370 Ordering :: SeqCst ) ;
@@ -391,15 +382,11 @@ impl Once {
391382 // poisoned or not.
392383 init ( state_and_queue == POISONED ) ;
393384 waiter_queue. set_state_on_drop_to = COMPLETE ;
394- return
385+ break
395386 }
396-
397- // All other values we find should correspond to the RUNNING
398- // state with an encoded waiter list in the more significant
399- // bits. We attempt to enqueue ourselves by moving us to the
400- // head of the list and bail out if we ever see a state that's
401- // not RUNNING.
402387 _ => {
388+ // All other values must be RUNNING with possibly a
389+ // pointer to the waiter queue in the more significant bits.
403390 assert ! ( state_and_queue & STATE_MASK == RUNNING ) ;
404391 wait ( & self . state_and_queue , state_and_queue) ;
405392 state_and_queue = self . state_and_queue . load ( Ordering :: SeqCst ) ;
0 commit comments