chore: apply unreachable_pub and missing_debug_implementations to all crates (#1424)

This commit is contained in:
Taiki Endo
2019-08-11 04:28:52 +09:00
committed by GitHub
parent d9f9c5658f
commit 6a125082e4
49 changed files with 322 additions and 225 deletions
+4 -4
View File
@@ -22,7 +22,7 @@ pub(crate) struct AtomicStackEntries {
const SHUTDOWN: *mut Entry = 1 as *mut _;
impl AtomicStack {
pub fn new() -> AtomicStack {
pub(crate) fn new() -> AtomicStack {
AtomicStack {
head: AtomicPtr::new(ptr::null_mut()),
}
@@ -32,7 +32,7 @@ impl AtomicStack {
///
/// Returns `true` if the entry was pushed, `false` if the entry is already
/// on the stack, `Err` if the timer is shutdown.
pub fn push(&self, entry: &Arc<Entry>) -> Result<bool, Error> {
pub(crate) fn push(&self, entry: &Arc<Entry>) -> Result<bool, Error> {
// First, set the queued bit on the entry
let queued = entry.queued.fetch_or(true, SeqCst);
@@ -72,14 +72,14 @@ impl AtomicStack {
}
/// Take all entries from the stack
pub fn take(&self) -> AtomicStackEntries {
pub(crate) fn take(&self) -> AtomicStackEntries {
let ptr = self.head.swap(ptr::null_mut(), SeqCst);
AtomicStackEntries { ptr }
}
/// Drain all remaining nodes in the stack and prevent any new nodes from
/// being pushed onto the stack.
pub fn shutdown(&self) {
pub(crate) fn shutdown(&self) {
// Shutdown the processing queue
let ptr = self.head.swap(SHUTDOWN, SeqCst);
+15 -15
View File
@@ -104,7 +104,7 @@ const ERROR: u64 = u64::MAX;
// ===== impl Entry =====
impl Entry {
pub fn new(deadline: Instant, duration: Duration) -> Entry {
pub(crate) fn new(deadline: Instant, duration: Duration) -> Entry {
Entry {
time: CachePadded::new(UnsafeCell::new(Time { deadline, duration })),
inner: None,
@@ -119,24 +119,24 @@ impl Entry {
}
/// Only called by `Registration`
pub fn time_ref(&self) -> &Time {
pub(crate) fn time_ref(&self) -> &Time {
unsafe { &*self.time.get() }
}
/// Only called by `Registration`
#[allow(clippy::mut_from_ref)] // https://github.com/rust-lang/rust-clippy/issues/4281
pub unsafe fn time_mut(&self) -> &mut Time {
pub(crate) unsafe fn time_mut(&self) -> &mut Time {
&mut *self.time.get()
}
/// Returns `true` if the `Entry` is currently associated with a timer
/// instance.
pub fn is_registered(&self) -> bool {
pub(crate) fn is_registered(&self) -> bool {
self.inner.is_some()
}
/// Only called by `Registration`
pub fn register(me: &mut Arc<Self>) {
pub(crate) fn register(me: &mut Arc<Self>) {
let handle = match HandlePriv::try_current() {
Ok(handle) => handle,
Err(_) => {
@@ -152,7 +152,7 @@ impl Entry {
}
/// Only called by `Registration`
pub fn register_with(me: &mut Arc<Self>, handle: HandlePriv) {
pub(crate) fn register_with(me: &mut Arc<Self>, handle: HandlePriv) {
assert!(!me.is_registered(), "only register an entry once");
let deadline = me.time_ref().deadline;
@@ -202,18 +202,18 @@ impl Entry {
/// The current entry state as known by the timer. This is not the value of
/// `state`, but lets the timer know how to converge its state to `state`.
pub fn when_internal(&self) -> Option<u64> {
pub(crate) fn when_internal(&self) -> Option<u64> {
unsafe { (*self.when.get()) }
}
pub fn set_when_internal(&self, when: Option<u64>) {
pub(crate) fn set_when_internal(&self, when: Option<u64>) {
unsafe {
(*self.when.get()) = when;
}
}
/// Called by `Timer` to load the current value of `state` for processing
pub fn load_state(&self) -> Option<u64> {
pub(crate) fn load_state(&self) -> Option<u64> {
let state = self.state.load(SeqCst);
if is_elapsed(state) {
@@ -223,12 +223,12 @@ impl Entry {
}
}
pub fn is_elapsed(&self) -> bool {
pub(crate) fn is_elapsed(&self) -> bool {
let state = self.state.load(SeqCst);
is_elapsed(state)
}
pub fn fire(&self, when: u64) {
pub(crate) fn fire(&self, when: u64) {
let mut curr = self.state.load(SeqCst);
loop {
@@ -249,7 +249,7 @@ impl Entry {
self.waker.wake();
}
pub fn error(&self) {
pub(crate) fn error(&self) {
// Only transition to the error state if not currently elapsed
let mut curr = self.state.load(SeqCst);
@@ -272,7 +272,7 @@ impl Entry {
self.waker.wake();
}
pub fn cancel(entry: &Arc<Entry>) {
pub(crate) fn cancel(entry: &Arc<Entry>) {
let state = entry.state.fetch_or(ELAPSED, SeqCst);
if is_elapsed(state) {
@@ -289,7 +289,7 @@ impl Entry {
let _ = inner.queue(entry);
}
pub fn poll_elapsed(&self, cx: &mut task::Context<'_>) -> Poll<Result<(), Error>> {
pub(crate) fn poll_elapsed(&self, cx: &mut task::Context<'_>) -> Poll<Result<(), Error>> {
let mut curr = self.state.load(SeqCst);
if is_elapsed(curr) {
@@ -316,7 +316,7 @@ impl Entry {
}
/// Only called by `Registration`
pub fn reset(entry: &mut Arc<Entry>) {
pub(crate) fn reset(entry: &mut Arc<Entry>) {
if !entry.is_registered() {
return;
}
+1
View File
@@ -7,4 +7,5 @@ pub trait Now {
fn now(&mut self) -> Instant;
}
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use crate::clock::Clock as SystemNow;
+8 -8
View File
@@ -14,7 +14,7 @@ pub(crate) struct Registration {
}
impl Registration {
pub fn new(deadline: Instant, duration: Duration) -> Registration {
pub(crate) fn new(deadline: Instant, duration: Duration) -> Registration {
fn is_send<T: Send + Sync>() {}
is_send::<Registration>();
@@ -23,21 +23,21 @@ impl Registration {
}
}
pub fn deadline(&self) -> Instant {
pub(crate) fn deadline(&self) -> Instant {
self.entry.time_ref().deadline
}
pub fn register(&mut self) {
pub(crate) fn register(&mut self) {
if !self.entry.is_registered() {
Entry::register(&mut self.entry)
}
}
pub fn register_with(&mut self, handle: HandlePriv) {
pub(crate) fn register_with(&mut self, handle: HandlePriv) {
Entry::register_with(&mut self.entry, handle)
}
pub fn reset(&mut self, deadline: Instant) {
pub(crate) fn reset(&mut self, deadline: Instant) {
unsafe {
self.entry.time_mut().deadline = deadline;
}
@@ -46,7 +46,7 @@ impl Registration {
// Used by `Timeout<Stream>`
#[cfg(feature = "async-traits")]
pub fn reset_timeout(&mut self) {
pub(crate) fn reset_timeout(&mut self) {
let deadline = crate::clock::now() + self.entry.time_ref().duration;
unsafe {
self.entry.time_mut().deadline = deadline;
@@ -54,11 +54,11 @@ impl Registration {
Entry::reset(&mut self.entry);
}
pub fn is_elapsed(&self) -> bool {
pub(crate) fn is_elapsed(&self) -> bool {
self.entry.is_elapsed()
}
pub fn poll_elapsed(&self, cx: &mut task::Context<'_>) -> Poll<Result<(), Error>> {
pub(crate) fn poll_elapsed(&self, cx: &mut task::Context<'_>) -> Poll<Result<(), Error>> {
self.entry.poll_elapsed(cx)
}
}