chore: apply rustfmt to all crates (#917)

This commit is contained in:
Carl Lerche
2019-02-21 11:56:15 -08:00
committed by GitHub
parent ab595d0825
commit 80162306e7
253 changed files with 3710 additions and 3407 deletions
+14 -17
View File
@@ -1,14 +1,14 @@
use pool::Pool;
use task::{Task, BlockingState};
use task::{BlockingState, Task};
use futures::{Poll, Async};
use futures::{Async, Poll};
use std::cell::UnsafeCell;
use std::fmt;
use std::ptr;
use std::sync::Arc;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::{Acquire, Release, AcqRel, Relaxed};
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
use std::sync::Arc;
use std::thread;
/// Manages the state around entering a blocking section and tasks that are
@@ -172,10 +172,10 @@ impl Blocking {
debug_assert_ne!(curr.0, 0);
debug_assert_ne!(next.0, 0);
let actual = self.state.compare_and_swap(
curr.into(),
next.into(),
AcqRel).into();
let actual = self
.state
.compare_and_swap(curr.into(), next.into(), AcqRel)
.into();
if curr == actual {
break;
@@ -190,8 +190,7 @@ impl Blocking {
// Finish pushing
unsafe {
(*prev).next_blocking
.store(ptr as *mut _, Release);
(*prev).next_blocking.store(ptr as *mut _, Release);
}
// The node was queued to be notified once capacity is made
@@ -245,7 +244,6 @@ impl Blocking {
pub fn notify_task(&self, pool: &Arc<Pool>) {
let prev = self.lock.fetch_add(1, AcqRel);
if prev != 0 {
// Another thread has the lock and will be responsible for notifying
// pending tasks.
@@ -287,8 +285,7 @@ impl Blocking {
/// there are no more tasks to pop, `rem` is used to set the remaining
/// capacity.
fn pop(&self, rem: usize) -> Option<Arc<Task>> {
'outer:
loop {
'outer: loop {
unsafe {
let mut tail = *self.tail.get();
let mut next = (*tail).next_blocking.load(Acquire);
@@ -330,10 +327,10 @@ impl Blocking {
// pops that will come after the current one.
after.add_capacity(rem + 1, &self.stub);
let actual: State = self.state.compare_and_swap(
curr.into(),
after.into(),
AcqRel).into();
let actual: State = self
.state
.compare_and_swap(curr.into(), after.into(), AcqRel)
.into();
if actual == curr {
// Successfully returned the remaining capacity
+33 -22
View File
@@ -9,14 +9,14 @@ use self::state::State;
use notifier::Notifier;
use pool::Pool;
use futures::{self, Future, Async};
use futures::executor::{self, Spawn};
use futures::{self, Async, Future};
use std::{fmt, panic, ptr};
use std::cell::{Cell, UnsafeCell};
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
use std::sync::atomic::{AtomicPtr, AtomicUsize};
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, AtomicPtr};
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release, Relaxed};
use std::{fmt, panic, ptr};
/// Harness around a future.
///
@@ -103,15 +103,20 @@ impl Task {
// Transition task to running state. At this point, the task must be
// scheduled.
let actual: State = self.state.compare_and_swap(
Scheduled.into(), Running.into(), AcqRel).into();
let actual: State = self
.state
.compare_and_swap(Scheduled.into(), Running.into(), AcqRel)
.into();
match actual {
Scheduled => {},
Scheduled => {}
_ => panic!("unexpected task state; {:?}", actual),
}
trace!("Task::run; state={:?}", State::from(self.state.load(Relaxed)));
trace!(
"Task::run; state={:?}",
State::from(self.state.load(Relaxed))
);
// The transition to `Running` done above ensures that a lock on the
// future has been obtained.
@@ -136,8 +141,10 @@ impl Task {
let mut g = Guard(fut, true);
let ret = g.0.as_mut().unwrap()
.poll_future_notify(unpark, self as *const _ as usize);
let ret =
g.0.as_mut()
.unwrap()
.poll_future_notify(unpark, self as *const _ as usize);
g.1 = false;
@@ -168,8 +175,10 @@ impl Task {
// fails, then the task has been unparked concurrent to running,
// in which case it transitions immediately back to scheduled
// and we return `true`.
let prev: State = self.state.compare_and_swap(
Running.into(), Idle.into(), AcqRel).into();
let prev: State = self
.state
.compare_and_swap(Running.into(), Idle.into(), AcqRel)
.into();
match prev {
Running => Run::Idle,
@@ -202,10 +211,10 @@ impl Task {
}
}
let actual = self.state.compare_and_swap(
state.into(),
Aborted.into(),
AcqRel).into();
let actual = self
.state
.compare_and_swap(state.into(), Aborted.into(), AcqRel)
.into();
if actual == state {
// The future has been aborted. Drop it immediately to free resources and run drop
@@ -239,10 +248,10 @@ impl Task {
loop {
// Scheduling can only be done from the `Idle` state.
let actual = self.state.compare_and_swap(
Idle.into(),
Scheduled.into(),
AcqRel).into();
let actual = self
.state
.compare_and_swap(Idle.into(), Scheduled.into(), AcqRel)
.into();
match actual {
Idle => return true,
@@ -250,8 +259,10 @@ impl Task {
// The task is already running on another thread. Transition
// the state to `Notified`. If this CAS fails, then restart
// the logic again from `Idle`.
let actual = self.state.compare_and_swap(
Running.into(), Notified.into(), AcqRel).into();
let actual = self
.state
.compare_and_swap(Running.into(), Notified.into(), AcqRel)
.into();
match actual {
Idle => continue,
+4 -2
View File
@@ -41,8 +41,10 @@ impl From<usize> for State {
use self::State::*;
debug_assert!(
src >= Idle as usize &&
src <= Aborted as usize, "actual={}", src);
src >= Idle as usize && src <= Aborted as usize,
"actual={}",
src
);
unsafe { ::std::mem::transmute(src) }
}