mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
Update Tokio to Rust 2018 (#1082)
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
use park::{BoxPark, BoxUnpark};
|
||||
use task::Task;
|
||||
use worker::state::{State, PUSHED_MASK};
|
||||
|
||||
use crate::park::{BoxPark, BoxUnpark};
|
||||
use crate::task::Task;
|
||||
use crate::worker::state::{State, PUSHED_MASK};
|
||||
use crossbeam_deque::{Steal, Stealer, Worker};
|
||||
use crossbeam_queue::SegQueue;
|
||||
use crossbeam_utils::CachePadded;
|
||||
use slab::Slab;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::fmt;
|
||||
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
|
||||
@@ -9,11 +12,6 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use crossbeam_deque::{Steal, Stealer, Worker};
|
||||
use crossbeam_queue::SegQueue;
|
||||
use crossbeam_utils::CachePadded;
|
||||
use slab::Slab;
|
||||
|
||||
// TODO: None of the fields should be public
|
||||
//
|
||||
// It would also be helpful to split up the state across what fields /
|
||||
@@ -96,7 +94,7 @@ impl WorkerEntry {
|
||||
/// The `state` must have been obtained with an `Acquire` ordering.
|
||||
#[inline]
|
||||
pub fn notify(&self, mut state: State) -> bool {
|
||||
use worker::Lifecycle::*;
|
||||
use crate::worker::Lifecycle::*;
|
||||
|
||||
loop {
|
||||
let mut next = state;
|
||||
@@ -141,7 +139,7 @@ impl WorkerEntry {
|
||||
///
|
||||
/// Returns `Err` if the worker has already terminated.
|
||||
pub fn signal_stop(&self, mut state: State) {
|
||||
use worker::Lifecycle::*;
|
||||
use crate::worker::Lifecycle::*;
|
||||
|
||||
// Transition the worker state to signaled
|
||||
loop {
|
||||
@@ -317,7 +315,7 @@ impl WorkerEntry {
|
||||
}
|
||||
|
||||
impl fmt::Debug for WorkerEntry {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("WorkerEntry")
|
||||
.field("state", &self.state.load(Relaxed))
|
||||
.field("next_sleeper", &"UnsafeCell<usize>")
|
||||
|
||||
@@ -6,16 +6,13 @@ pub(crate) use self::entry::WorkerEntry as Entry;
|
||||
pub(crate) use self::stack::Stack;
|
||||
pub(crate) use self::state::{Lifecycle, State};
|
||||
|
||||
use notifier::Notifier;
|
||||
use pool::{self, BackupId, Pool};
|
||||
use sender::Sender;
|
||||
use shutdown::ShutdownTrigger;
|
||||
use task::{self, CanBlock, Task};
|
||||
|
||||
use tokio_executor;
|
||||
|
||||
use crate::notifier::Notifier;
|
||||
use crate::pool::{self, BackupId, Pool};
|
||||
use crate::sender::Sender;
|
||||
use crate::shutdown::ShutdownTrigger;
|
||||
use crate::task::{self, CanBlock, Task};
|
||||
use futures::{Async, Poll};
|
||||
|
||||
use log::trace;
|
||||
use std::cell::Cell;
|
||||
use std::marker::PhantomData;
|
||||
use std::rc::Rc;
|
||||
@@ -23,6 +20,7 @@ use std::sync::atomic::Ordering::{AcqRel, Acquire};
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use tokio_executor;
|
||||
|
||||
/// Thread worker
|
||||
///
|
||||
@@ -150,7 +148,7 @@ impl Worker {
|
||||
}
|
||||
|
||||
/// Transition the current worker to a blocking worker
|
||||
pub(crate) fn transition_to_blocking(&self) -> Poll<(), ::BlockingError> {
|
||||
pub(crate) fn transition_to_blocking(&self) -> Poll<(), crate::BlockingError> {
|
||||
use self::CanBlock::*;
|
||||
|
||||
// If we get this far, then `current_task` has been set.
|
||||
@@ -447,7 +445,7 @@ impl Worker {
|
||||
}
|
||||
|
||||
fn run_task(&self, task: Arc<Task>, notify: &Arc<Notifier>) {
|
||||
use task::Run::*;
|
||||
use crate::task::Run::*;
|
||||
|
||||
// If this is the first time this task is being polled, register it so that we can keep
|
||||
// track of tasks that are in progress.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use config::MAX_WORKERS;
|
||||
use worker;
|
||||
|
||||
use crate::config::MAX_WORKERS;
|
||||
use crate::worker;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed};
|
||||
use std::{fmt, usize};
|
||||
@@ -242,7 +241,7 @@ impl From<State> for usize {
|
||||
}
|
||||
|
||||
impl fmt::Debug for State {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let head = self.head();
|
||||
|
||||
let mut fmt = fmt.debug_struct("stack::State");
|
||||
|
||||
@@ -93,7 +93,7 @@ impl From<State> for usize {
|
||||
}
|
||||
|
||||
impl fmt::Debug for State {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("worker::State")
|
||||
.field("lifecycle", &self.lifecycle())
|
||||
.field("is_pushed", &self.is_pushed())
|
||||
|
||||
Reference in New Issue
Block a user