mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
ci: enable clippy lints (#1335)
This commit is contained in:
@@ -393,7 +393,7 @@ impl State {
|
||||
State((capacity << NUM_SHIFT) | NUM_FLAG)
|
||||
}
|
||||
|
||||
fn remaining_capacity(&self) -> usize {
|
||||
fn remaining_capacity(self) -> usize {
|
||||
if !self.has_remaining_capacity() {
|
||||
return 0;
|
||||
}
|
||||
@@ -401,15 +401,15 @@ impl State {
|
||||
self.0 >> 1
|
||||
}
|
||||
|
||||
fn has_remaining_capacity(&self) -> bool {
|
||||
fn has_remaining_capacity(self) -> bool {
|
||||
self.0 & NUM_FLAG == NUM_FLAG
|
||||
}
|
||||
|
||||
fn has_task(&self, stub: &Task) -> bool {
|
||||
fn has_task(self, stub: &Task) -> bool {
|
||||
!(self.has_remaining_capacity() || self.is_stub(stub))
|
||||
}
|
||||
|
||||
fn is_stub(&self, stub: &Task) -> bool {
|
||||
fn is_stub(self, stub: &Task) -> bool {
|
||||
self.0 == stub as *const _ as usize
|
||||
}
|
||||
|
||||
@@ -452,11 +452,11 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_ptr(&self) -> bool {
|
||||
fn is_ptr(self) -> bool {
|
||||
self.0 & NUM_FLAG == 0
|
||||
}
|
||||
|
||||
fn ptr(&self) -> Option<*const Task> {
|
||||
fn ptr(self) -> Option<*const Task> {
|
||||
if self.is_ptr() {
|
||||
Some(self.0 as *const Task)
|
||||
} else {
|
||||
|
||||
@@ -18,26 +18,26 @@ const ALLOCATED: usize = 0b10;
|
||||
|
||||
impl BlockingState {
|
||||
/// Create a new, default, `BlockingState`.
|
||||
pub fn new() -> BlockingState {
|
||||
pub(crate) fn new() -> BlockingState {
|
||||
BlockingState(0)
|
||||
}
|
||||
|
||||
/// Returns `true` if the state represents the associated task being queued
|
||||
/// in the pending blocking capacity channel
|
||||
pub fn is_queued(&self) -> bool {
|
||||
pub(crate) fn is_queued(&self) -> bool {
|
||||
self.0 & QUEUED == QUEUED
|
||||
}
|
||||
|
||||
/// Toggle the queued flag
|
||||
///
|
||||
/// Returns the state before the flag has been toggled.
|
||||
pub fn toggle_queued(state: &AtomicUsize, ordering: Ordering) -> BlockingState {
|
||||
pub(crate) fn toggle_queued(state: &AtomicUsize, ordering: Ordering) -> BlockingState {
|
||||
state.fetch_xor(QUEUED, ordering).into()
|
||||
}
|
||||
|
||||
/// Returns `true` if the state represents the associated task having been
|
||||
/// allocated capacity to block.
|
||||
pub fn is_allocated(&self) -> bool {
|
||||
pub(crate) fn is_allocated(&self) -> bool {
|
||||
self.0 & ALLOCATED == ALLOCATED
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ impl BlockingState {
|
||||
///
|
||||
/// If this returns `true`, then the task has the ability to block for the
|
||||
/// duration of the `poll`.
|
||||
pub fn consume_allocation(state: &AtomicUsize, ordering: Ordering) -> CanBlock {
|
||||
pub(crate) fn consume_allocation(state: &AtomicUsize, ordering: Ordering) -> CanBlock {
|
||||
let state: Self = state.fetch_and(!ALLOCATED, ordering).into();
|
||||
|
||||
if state.is_allocated() {
|
||||
@@ -58,7 +58,7 @@ impl BlockingState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn notify_blocking(state: &AtomicUsize, ordering: Ordering) {
|
||||
pub(crate) fn notify_blocking(state: &AtomicUsize, ordering: Ordering) {
|
||||
let prev: Self = state.fetch_xor(ALLOCATED | QUEUED, ordering).into();
|
||||
|
||||
debug_assert!(prev.is_queued());
|
||||
|
||||
@@ -134,12 +134,12 @@ impl Task {
|
||||
|
||||
let mut g = Guard(fut, true);
|
||||
|
||||
let mut waker = arc_waker::waker(Arc::new(Waker {
|
||||
let waker = arc_waker::waker(Arc::new(Waker {
|
||||
task: me.clone(),
|
||||
pool: pool.clone(),
|
||||
}));
|
||||
|
||||
let mut cx = Context::from_waker(&mut waker);
|
||||
let mut cx = Context::from_waker(&waker);
|
||||
|
||||
let ret = g.0.as_mut().unwrap().as_mut().poll(&mut cx);
|
||||
|
||||
@@ -239,7 +239,7 @@ impl Task {
|
||||
pub fn schedule(me: &Arc<Self>, pool: &Arc<Pool>) {
|
||||
if me.schedule2() {
|
||||
let task = me.clone();
|
||||
let _ = pool.submit(task, &pool);
|
||||
pool.submit(task, &pool);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ impl State {
|
||||
///
|
||||
/// Tasks start in the scheduled state as they are immediately scheduled on
|
||||
/// creation.
|
||||
pub fn new() -> State {
|
||||
pub(crate) fn new() -> State {
|
||||
State::Scheduled
|
||||
}
|
||||
|
||||
pub fn stub() -> State {
|
||||
pub(crate) fn stub() -> State {
|
||||
State::Idle
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user