From 4436c9d35498e7ae3da261f6141d6d73b915e1e8 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 27 Nov 2019 10:29:00 -0800 Subject: Format libstd with rustfmt This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference --- src/libstd/sync/mpsc/spsc_queue.rs | 47 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'src/libstd/sync/mpsc/spsc_queue.rs') diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index 0edb1c24e80..c51aa7619db 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -6,8 +6,8 @@ // http://www.1024cores.net/home/lock-free-algorithms/queues/unbounded-spsc-queue -use core::ptr; use core::cell::UnsafeCell; +use core::ptr; use crate::boxed::Box; use crate::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; @@ -19,16 +19,16 @@ struct Node { // FIXME: this could be an uninitialized T if we're careful enough, and // that would reduce memory usage (and be a bit faster). // is it worth it? - value: Option, // nullable for re-use of nodes - cached: bool, // This node goes into the node cache - next: AtomicPtr>, // next node in the queue + value: Option, // nullable for re-use of nodes + cached: bool, // This node goes into the node cache + next: AtomicPtr>, // next node in the queue } /// The single-producer single-consumer queue. This structure is not cloneable, /// but it can be safely shared in an Arc if it is guaranteed that there /// is only one popper and one pusher touching the queue at any one point in /// time. -pub struct Queue { +pub struct Queue { // consumer fields consumer: CacheAligned>, @@ -38,9 +38,9 @@ pub struct Queue { struct Consumer { tail: UnsafeCell<*mut Node>, // where to pop from - tail_prev: AtomicPtr>, // where to pop from - cache_bound: usize, // maximum cache size - cached_nodes: AtomicUsize, // number of nodes marked as cachable + tail_prev: AtomicPtr>, // where to pop from + cache_bound: usize, // maximum cache size + cached_nodes: AtomicUsize, // number of nodes marked as cachable addition: Addition, } @@ -51,9 +51,9 @@ struct Producer { addition: Addition, } -unsafe impl Send for Queue { } +unsafe impl Send for Queue {} -unsafe impl Sync for Queue { } +unsafe impl Sync for Queue {} impl Node { fn new() -> *mut Node { @@ -66,7 +66,6 @@ impl Node { } impl Queue { - /// Creates a new queue. With given additional elements in the producer and /// consumer portions of the queue. /// @@ -107,13 +106,13 @@ impl Queue Queue Queue Queue> = Box::from_raw(tail); @@ -234,9 +235,9 @@ impl Drop for Queue { assert_eq!(&*vec, &[1]); - }, - None => unreachable!() + } + None => unreachable!(), } match queue.pop() { Some(vec) => { assert_eq!(&*vec, &[1]); - }, - None => unreachable!() + } + None => unreachable!(), } } } @@ -316,7 +317,7 @@ mod tests { let (tx, rx) = channel(); let q2 = q.clone(); - let _t = thread::spawn(move|| { + let _t = thread::spawn(move || { for _ in 0..100000 { loop { match q2.pop() { -- cgit 1.4.1-3-g733a5