Skip to content

Rollup of 7 pull requests #66259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Nov 10, 2019
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2ab812c
Rename state to state_and_queue
pitdicker Oct 23, 2019
7f1e166
Simplify loop conditions in RUNNING and add comments
pitdicker Oct 23, 2019
1479c22
Don't mutate waiter nodes
pitdicker Oct 23, 2019
fbc242f
Turn Finish into WaiterQueue
pitdicker Oct 23, 2019
2e8eb5f
Move thread parking to a seperate function
pitdicker Oct 23, 2019
4b8da9c
Reduce the amount of comments in call_inner
pitdicker Oct 23, 2019
88c70ed
In Waiter use interior mutability for thread
pitdicker Oct 23, 2019
c11a44a
Use more precise atomic orderings
pitdicker Oct 23, 2019
c2bbfea
Always align Waiter to 4 bytes
pitdicker Oct 24, 2019
3712bb6
Mention park guarantee
pitdicker Oct 25, 2019
972c3be
Don't cast directly from `&[T; N]` to `*const T`
matthewjasper Oct 25, 2019
6eddf5c
Correct error in documentation for Ipv4Addr method
mjptree Nov 2, 2019
6f79b71
Correct deprecated `is_global` IPv6 documentation
mjptree Nov 3, 2019
4c66658
Don't mutate node.next
pitdicker Nov 4, 2019
0da85d6
rustc_metadata: don't let LLVM confuse rmeta blobs for COFF object fi…
eddyb Nov 9, 2019
8316701
[mir-opt] Handle const-prop for the return place
wesleywiser Nov 8, 2019
4505ff4
[mir-opt] Handle aggregates in SimplifyLocals pass
wesleywiser Nov 8, 2019
769d527
partially port invalid_value lint to diagnostic items
RalfJung Nov 9, 2019
b05e200
Run rustfmt on libstd/sync/once.rs
pitdicker Nov 9, 2019
15863a6
Update src/libstd/net/ip.rs
mjptree Nov 9, 2019
e88aa39
Rollup merge of #65719 - pitdicker:refactor_sync_once, r=Amanieu
JohnTitor Nov 10, 2019
401d9e1
Rollup merge of #65831 - matthewjasper:array-ptr-cast, r=oli-obk
JohnTitor Nov 10, 2019
41d335e
Rollup merge of #66048 - mjptree:patch-1, r=Dylan-DPC
JohnTitor Nov 10, 2019
f135e33
Rollup merge of #66058 - mjptree:patch-2, r=kennytm
JohnTitor Nov 10, 2019
f166609
Rollup merge of #66216 - wesleywiser:const_prop_codegen_improvements,…
JohnTitor Nov 10, 2019
9db3fdd
Rollup merge of #66217 - RalfJung:diagnostic-items, r=Centril
JohnTitor Nov 10, 2019
0fec5ab
Rollup merge of #66235 - eddyb:coff-syrup, r=nagisa
JohnTitor Nov 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reduce the amount of comments in call_inner
  • Loading branch information
pitdicker committed Oct 24, 2019
commit 4b8da9ccd528d46637c88a40f6cdd0d634c0fb22
25 changes: 6 additions & 19 deletions src/libstd/sync/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,25 +355,16 @@ impl Once {
// performance difference really does not matter there, and
// SeqCst minimizes the chances of something going wrong.
let mut state_and_queue = self.state_and_queue.load(Ordering::SeqCst);

loop {
match state_and_queue {
// If we're complete, then there's nothing to do, we just
// jettison out as we shouldn't run the closure.
COMPLETE => return,

// If we're poisoned and we're not in a mode to ignore
// poisoning, then we panic here to propagate the poison.
COMPLETE => break,
POISONED if !ignore_poisoning => {
// Panic to propagate the poison.
panic!("Once instance has previously been poisoned");
}

// Otherwise if we see a poisoned or otherwise incomplete state
// we will attempt to move ourselves into the RUNNING state. If
// we succeed, then the queue of waiters starts at null (all 0
// bits).
POISONED |
INCOMPLETE => {
// Try to register this thread as the one RUNNING.
let old = self.state_and_queue.compare_and_swap(state_and_queue,
RUNNING,
Ordering::SeqCst);
Expand All @@ -391,15 +382,11 @@ impl Once {
// poisoned or not.
init(state_and_queue == POISONED);
waiter_queue.set_state_on_drop_to = COMPLETE;
return
break
}

// All other values we find should correspond to the RUNNING
// state with an encoded waiter list in the more significant
// bits. We attempt to enqueue ourselves by moving us to the
// head of the list and bail out if we ever see a state that's
// not RUNNING.
_ => {
// All other values must be RUNNING with possibly a
// pointer to the waiter queue in the more significant bits.
assert!(state_and_queue & STATE_MASK == RUNNING);
wait(&self.state_and_queue, state_and_queue);
state_and_queue = self.state_and_queue.load(Ordering::SeqCst);
Expand Down