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
+2 -2
View File
@@ -8,14 +8,14 @@ pub(crate) struct Callback {
}
impl Callback {
pub fn new<F>(f: F) -> Self
pub(crate) fn new<F>(f: F) -> Self
where
F: Fn(&Worker) + Send + Sync + 'static,
{
Callback { f: Arc::new(f) }
}
pub fn call(&self, worker: &Worker) {
pub(crate) fn call(&self, worker: &Worker) {
(self.f)(worker)
}
}
+7 -7
View File
@@ -7,14 +7,14 @@ use std::time::Duration;
/// Thread pool specific configuration values
#[derive(Clone)]
pub(crate) struct Config {
pub keep_alive: Option<Duration>,
pub(crate) keep_alive: Option<Duration>,
// Used to configure a worker thread
pub name_prefix: Option<String>,
pub stack_size: Option<usize>,
pub around_worker: Option<Callback>,
pub after_start: Option<Arc<dyn Fn() + Send + Sync>>,
pub before_stop: Option<Arc<dyn Fn() + Send + Sync>>,
pub panic_handler: Option<PanicHandler>,
pub(crate) name_prefix: Option<String>,
pub(crate) stack_size: Option<usize>,
pub(crate) around_worker: Option<Callback>,
pub(crate) after_start: Option<Arc<dyn Fn() + Send + Sync>>,
pub(crate) before_stop: Option<Arc<dyn Fn() + Send + Sync>>,
pub(crate) panic_handler: Option<PanicHandler>,
}
// Define type alias to avoid clippy::type_complexity.
+6 -1
View File
@@ -1,5 +1,10 @@
#![doc(html_root_url = "https://docs.rs/tokio-threadpool/0.2.0-alpha.1")]
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![warn(
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
unreachable_pub
)]
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
//! A work-stealing based thread pool for executing futures.
+1 -1
View File
@@ -9,7 +9,7 @@ pub(crate) type BoxUnpark = Box<dyn Unpark>;
pub(crate) struct BoxedPark<T>(T);
impl<T> BoxedPark<T> {
pub fn new(inner: T) -> Self {
pub(crate) fn new(inner: T) -> Self {
BoxedPark(inner)
}
}
+14 -14
View File
@@ -67,18 +67,18 @@ struct State(usize);
/// This flag also serves as a "notification" bit. If another thread is
/// attempting to hand off a worker to the backup thread, then the pushed bit
/// will not be set when the thread tries to shutdown.
pub const PUSHED: usize = 0b001;
pub(crate) const PUSHED: usize = 0b001;
/// Set when the thread is running
pub const RUNNING: usize = 0b010;
pub(crate) const RUNNING: usize = 0b010;
/// Set when the thread pool has terminated
pub const TERMINATED: usize = 0b100;
pub(crate) const TERMINATED: usize = 0b100;
// ===== impl Backup =====
impl Backup {
pub fn new() -> Backup {
pub(crate) fn new() -> Backup {
Backup {
handoff: UnsafeCell::new(None),
state: AtomicUsize::new(State::new().into()),
@@ -88,7 +88,7 @@ impl Backup {
}
/// Called when the thread is starting
pub fn start(&self, worker_id: &WorkerId) {
pub(crate) fn start(&self, worker_id: &WorkerId) {
debug_assert!({
let state: State = self.state.load(Relaxed).into();
@@ -107,7 +107,7 @@ impl Backup {
}
}
pub fn is_running(&self) -> bool {
pub(crate) fn is_running(&self) -> bool {
let state: State = self.state.load(Relaxed).into();
state.is_running()
}
@@ -115,7 +115,7 @@ impl Backup {
/// Hands off the worker to a thread.
///
/// Returns `true` if the thread needs to be spawned.
pub fn worker_handoff(&self, worker_id: WorkerId) -> bool {
pub(crate) fn worker_handoff(&self, worker_id: WorkerId) -> bool {
unsafe {
// The backup worker should not already have been handoff a worker.
debug_assert!((*self.handoff.get()).is_none());
@@ -139,7 +139,7 @@ impl Backup {
}
/// Terminate the worker
pub fn signal_stop(&self) {
pub(crate) fn signal_stop(&self) {
let prev: State = self.state.fetch_xor(TERMINATED | PUSHED, AcqRel).into();
debug_assert!(!prev.is_terminated());
@@ -151,14 +151,14 @@ impl Backup {
}
/// Release the worker
pub fn release(&self) {
pub(crate) fn release(&self) {
let prev: State = self.state.fetch_xor(RUNNING, AcqRel).into();
debug_assert!(prev.is_running());
}
/// Wait for a worker handoff
pub fn wait_for_handoff(&self, timeout: Option<Duration>) -> Handoff {
pub(crate) fn wait_for_handoff(&self, timeout: Option<Duration>) -> Handoff {
let sleep_until = timeout.map(|dur| Instant::now() + dur);
let mut state: State = self.state.load(Acquire).into();
@@ -208,23 +208,23 @@ impl Backup {
}
}
pub fn is_pushed(&self) -> bool {
pub(crate) fn is_pushed(&self) -> bool {
let state: State = self.state.load(Relaxed).into();
state.is_pushed()
}
pub fn set_pushed(&self, ordering: Ordering) {
pub(crate) fn set_pushed(&self, ordering: Ordering) {
let prev: State = self.state.fetch_or(PUSHED, ordering).into();
debug_assert!(!prev.is_pushed());
}
#[inline]
pub fn next_sleeper(&self) -> BackupId {
pub(crate) fn next_sleeper(&self) -> BackupId {
unsafe { *self.next_sleeper.get() }
}
#[inline]
pub fn set_next_sleeper(&self, val: BackupId) {
pub(crate) fn set_next_sleeper(&self, val: BackupId) {
unsafe {
*self.next_sleeper.get() = val;
}
+3 -3
View File
@@ -34,7 +34,7 @@ const ABA_GUARD_MASK: usize = (1 << (32 - ABA_GUARD_SHIFT)) - 1;
// ===== impl BackupStack =====
impl BackupStack {
pub fn new() -> BackupStack {
pub(crate) fn new() -> BackupStack {
let state = AtomicUsize::new(State::new().into());
BackupStack { state }
}
@@ -47,7 +47,7 @@ impl BackupStack {
///
/// Returns `Err` if the pool has transitioned to the `TERMINATED` state.
/// When terminated, pushing new entries is no longer permitted.
pub fn push(&self, entries: &[Backup], id: BackupId) -> Result<(), ()> {
pub(crate) fn push(&self, entries: &[Backup], id: BackupId) -> Result<(), ()> {
let mut state: State = self.state.load(Acquire).into();
entries[id.0].set_pushed(AcqRel);
@@ -91,7 +91,7 @@ impl BackupStack {
///
/// * `Ok(None)` if the stack is empty.
/// * `Err(_)` is returned if the pool has been shutdown.
pub fn pop(&self, entries: &[Backup], terminate: bool) -> Result<Option<BackupId>, ()> {
pub(crate) fn pop(&self, entries: &[Backup], terminate: bool) -> Result<Option<BackupId>, ()> {
// Figure out the empty value
let terminal = if terminate { TERMINATED } else { EMPTY };
+18 -18
View File
@@ -38,7 +38,7 @@ pub(crate) struct Pool {
//
// The value of this atomic is deserialized into a `pool::State` instance.
// See comments for that type.
pub state: CachePadded<AtomicUsize>,
pub(crate) state: CachePadded<AtomicUsize>,
// Stack tracking sleeping workers.
sleep_stack: CachePadded<worker::Stack>,
@@ -49,19 +49,19 @@ pub(crate) struct Pool {
// futures.
//
// The number of workers will *usually* be small.
pub workers: Arc<[worker::Entry]>,
pub(crate) workers: Arc<[worker::Entry]>,
// The global MPMC queue of tasks.
//
// Spawned tasks are pushed into this queue. Although worker threads have their own dedicated
// task queues, they periodically steal tasks from this global queue, too.
pub queue: Arc<Injector<Arc<Task>>>,
pub(crate) queue: Arc<Injector<Arc<Task>>>,
// Completes the shutdown process when the `ThreadPool` and all `Worker`s get dropped.
//
// When spawning a new `Worker`, this weak reference is upgraded and handed out to the new
// thread.
pub trigger: Weak<ShutdownTrigger>,
pub(crate) trigger: Weak<ShutdownTrigger>,
// Backup thread state
//
@@ -71,19 +71,19 @@ pub(crate) struct Pool {
backup: Box<[Backup]>,
// Stack of sleeping backup threads
pub backup_stack: BackupStack,
pub(crate) backup_stack: BackupStack,
// State regarding coordinating blocking sections and tracking tasks that
// are pending blocking capacity.
blocking: Blocking,
// Configuration
pub config: Config,
pub(crate) config: Config,
}
impl Pool {
/// Create a new `Pool`
pub fn new(
pub(crate) fn new(
workers: Arc<[worker::Entry]>,
trigger: Weak<ShutdownTrigger>,
max_blocking: usize,
@@ -133,7 +133,7 @@ impl Pool {
/// Start shutting down the pool. This means that no new futures will be
/// accepted.
pub fn shutdown(&self, now: bool, purge_queue: bool) {
pub(crate) fn shutdown(&self, now: bool, purge_queue: bool) {
let mut state: State = self.state.load(Acquire).into();
trace!("shutdown; state={:?}", state);
@@ -198,11 +198,11 @@ impl Pool {
/// Called by `Worker` as it tries to enter a sleeping state. Before it
/// sleeps, it must push itself onto the sleep stack. This enables other
/// threads to see it when signaling work.
pub fn push_sleeper(&self, idx: usize) -> Result<(), ()> {
pub(crate) fn push_sleeper(&self, idx: usize) -> Result<(), ()> {
self.sleep_stack.push(&self.workers, idx)
}
pub fn terminate_sleeping_workers(&self) {
pub(crate) fn terminate_sleeping_workers(&self) {
use crate::worker::Lifecycle::Signaled;
trace!(" -> shutting down workers");
@@ -222,7 +222,7 @@ impl Pool {
}
}
pub fn poll_blocking_capacity(
pub(crate) fn poll_blocking_capacity(
&self,
task: &Arc<Task>,
) -> Poll<Result<(), crate::BlockingError>> {
@@ -233,7 +233,7 @@ impl Pool {
///
/// Called from either inside or outside of the scheduler. If currently on
/// the scheduler, then a fast path is taken.
pub fn submit(&self, task: Arc<Task>, pool: &Arc<Pool>) {
pub(crate) fn submit(&self, task: Arc<Task>, pool: &Arc<Pool>) {
debug_assert_eq!(*self, **pool);
Worker::with_current(|worker| {
@@ -265,7 +265,7 @@ impl Pool {
///
/// Called from outside of the scheduler, this function is how new tasks
/// enter the system.
pub fn submit_external(&self, task: Arc<Task>, pool: &Arc<Pool>) {
pub(crate) fn submit_external(&self, task: Arc<Task>, pool: &Arc<Pool>) {
debug_assert_eq!(*self, **pool);
trace!(" -> submit external");
@@ -274,7 +274,7 @@ impl Pool {
self.signal_work(pool);
}
pub fn release_backup(&self, backup_id: BackupId) -> Result<(), ()> {
pub(crate) fn release_backup(&self, backup_id: BackupId) -> Result<(), ()> {
// First update the state, this cannot fail because the caller must have
// exclusive access to the backup token.
self.backup[backup_id.0].release();
@@ -283,13 +283,13 @@ impl Pool {
self.backup_stack.push(&self.backup, backup_id)
}
pub fn notify_blocking_task(&self, pool: &Arc<Pool>) {
pub(crate) fn notify_blocking_task(&self, pool: &Arc<Pool>) {
debug_assert_eq!(*self, **pool);
self.blocking.notify_task(&pool);
}
/// Provision a thread to run a worker
pub fn spawn_thread(&self, id: WorkerId, pool: &Arc<Pool>) {
pub(crate) fn spawn_thread(&self, id: WorkerId, pool: &Arc<Pool>) {
debug_assert_eq!(*self, **pool);
let backup_id = match self.backup_stack.pop(&self.backup, false) {
@@ -396,7 +396,7 @@ impl Pool {
/// If there are any other workers currently relaxing, signal them that work
/// is available so that they can try to find more work to process.
pub fn signal_work(&self, pool: &Arc<Pool>) {
pub(crate) fn signal_work(&self, pool: &Arc<Pool>) {
debug_assert_eq!(*self, **pool);
use crate::worker::Lifecycle::Signaled;
@@ -422,7 +422,7 @@ impl Pool {
/// Generates a random number
///
/// Uses a thread-local random number generator based on XorShift.
pub fn rand_usize(&self) -> usize {
pub(crate) fn rand_usize(&self) -> usize {
thread_local! {
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(prng_seed()));
}
+3 -3
View File
@@ -85,7 +85,7 @@ const NUM_SHIFT: usize = 1;
//
impl Blocking {
/// Create a new `Blocking`.
pub fn new(capacity: usize) -> Blocking {
pub(crate) fn new(capacity: usize) -> Blocking {
assert!(capacity > 0, "blocking capacity must be greater than zero");
let stub = Box::new(Task::stub());
@@ -110,7 +110,7 @@ impl Blocking {
///
/// The caller must ensure that `task` has not previously been queued to be
/// notified when capacity becomes available.
pub fn poll_blocking_capacity(
pub(crate) fn poll_blocking_capacity(
&self,
task: &Arc<Task>,
) -> Poll<Result<(), crate::BlockingError>> {
@@ -243,7 +243,7 @@ impl Blocking {
(*prev).next_blocking.store(task, Release);
}
pub fn notify_task(&self, pool: &Arc<Pool>) {
pub(crate) fn notify_task(&self, pool: &Arc<Pool>) {
let prev = self.lock.fetch_add(1, AcqRel);
if prev != 0 {
+8 -8
View File
@@ -40,13 +40,13 @@ pub(crate) struct Task {
///
/// The worker ID is represented by a `u32` rather than `usize` in order to save some space
/// on 64-bit platforms.
pub reg_worker: Cell<Option<u32>>,
pub(crate) reg_worker: Cell<Option<u32>>,
/// The key associated with this task in the `Slab` it was registered in.
///
/// This field can be a `Cell` because it's only accessed by the worker thread that has
/// registered the task.
pub reg_index: Cell<usize>,
pub(crate) reg_index: Cell<usize>,
/// Store the future at the head of the struct
///
@@ -67,7 +67,7 @@ type BoxFuture = Pin<Box<dyn Future<Output = ()> + Send + 'static>>;
impl Task {
/// Create a new `Task` as a harness for `future`.
pub fn new(future: BoxFuture) -> Task {
pub(crate) fn new(future: BoxFuture) -> Task {
Task {
state: AtomicUsize::new(State::new().into()),
blocking: AtomicUsize::new(BlockingState::new().into()),
@@ -95,7 +95,7 @@ impl Task {
/// Execute the task returning `Run::Schedule` if the task needs to be
/// scheduled again.
pub fn run(me: &Arc<Task>, pool: &Arc<Pool>) -> Run {
pub(crate) fn run(me: &Arc<Task>, pool: &Arc<Pool>) -> Run {
use self::State::*;
// Transition task to running state. At this point, the task must be
@@ -200,7 +200,7 @@ impl Task {
///
/// This is called when the threadpool shuts down and the task has already beed polled but not
/// completed.
pub fn abort(&self) {
pub(crate) fn abort(&self) {
use self::State::*;
let mut state = self.state.load(Acquire).into();
@@ -232,12 +232,12 @@ impl Task {
}
/// Notify the task it has been allocated blocking capacity
pub fn notify_blocking(me: Arc<Task>, pool: &Arc<Pool>) {
pub(crate) fn notify_blocking(me: Arc<Task>, pool: &Arc<Pool>) {
BlockingState::notify_blocking(&me.blocking, AcqRel);
Task::schedule(&me, pool);
}
pub fn schedule(me: &Arc<Self>, pool: &Arc<Pool>) {
pub(crate) fn schedule(me: &Arc<Self>, pool: &Arc<Pool>) {
if me.schedule2() {
let task = me.clone();
pool.submit(task, &pool);
@@ -281,7 +281,7 @@ impl Task {
/// Consumes any allocated capacity to block.
///
/// Returns `true` if capacity was allocated, `false` otherwise.
pub fn consume_blocking_allocation(&self) -> CanBlock {
pub(crate) fn consume_blocking_allocation(&self) -> CanBlock {
// This flag is the primary point of coordination. The queued flag
// happens "around" setting the blocking capacity.
BlockingState::consume_allocation(&self.blocking, AcqRel)
+2 -2
View File
@@ -10,8 +10,8 @@ use std::sync::Arc;
/// to poll the future again.
#[derive(Debug)]
pub(crate) struct Waker {
pub pool: Arc<Pool>,
pub task: Arc<Task>,
pub(crate) pool: Arc<Pool>,
pub(crate) task: Arc<Task>,
}
unsafe impl Send for Waker {}
+20 -20
View File
@@ -21,13 +21,13 @@ pub(crate) struct WorkerEntry {
//
// The `usize` value is deserialized to a `worker::State` instance. See
// comments on that type.
pub state: CachePadded<AtomicUsize>,
pub(crate) state: CachePadded<AtomicUsize>,
// Next entry in the parked Trieber stack
next_sleeper: UnsafeCell<usize>,
// Worker half of deque
pub worker: Worker<Arc<Task>>,
pub(crate) worker: Worker<Arc<Task>>,
// Stealer half of deque
stealer: Stealer<Arc<Task>>,
@@ -50,7 +50,7 @@ pub(crate) struct WorkerEntry {
}
impl WorkerEntry {
pub fn new(park: BoxPark, unpark: BoxUnpark) -> Self {
pub(crate) fn new(park: BoxPark, unpark: BoxUnpark) -> Self {
let w = Worker::new_fifo();
let s = w.stealer();
@@ -76,14 +76,14 @@ impl WorkerEntry {
/// # Ordering
///
/// The specified ordering is established on the entry's state variable.
pub fn fetch_unset_pushed(&self, ordering: Ordering) -> State {
pub(crate) fn fetch_unset_pushed(&self, ordering: Ordering) -> State {
self.state.fetch_and(!PUSHED_MASK, ordering).into()
}
/// Submit a task to this worker while currently on the same thread that is
/// running the worker.
#[inline]
pub fn submit_internal(&self, task: Arc<Task>) {
pub(crate) fn submit_internal(&self, task: Arc<Task>) {
self.push_internal(task);
}
@@ -93,7 +93,7 @@ impl WorkerEntry {
///
/// The `state` must have been obtained with an `Acquire` ordering.
#[inline]
pub fn notify(&self, mut state: State) -> bool {
pub(crate) fn notify(&self, mut state: State) -> bool {
use crate::worker::Lifecycle::*;
loop {
@@ -138,7 +138,7 @@ impl WorkerEntry {
/// Returns `Ok` when the worker was successfully signaled.
///
/// Returns `Err` if the worker has already terminated.
pub fn signal_stop(&self, mut state: State) {
pub(crate) fn signal_stop(&self, mut state: State) {
use crate::worker::Lifecycle::*;
// Transition the worker state to signaled
@@ -189,7 +189,7 @@ impl WorkerEntry {
/// This **must** only be called by the thread that owns the worker entry.
/// This function is not `Sync`.
#[inline]
pub fn pop_task(&self) -> Option<Arc<Task>> {
pub(crate) fn pop_task(&self) -> Option<Arc<Task>> {
self.worker.pop()
}
@@ -201,26 +201,26 @@ impl WorkerEntry {
/// At the same time, this method steals some additional tasks and moves
/// them into `dest` in order to balance the work distribution among
/// workers.
pub fn steal_tasks(&self, dest: &Self) -> Steal<Arc<Task>> {
pub(crate) fn steal_tasks(&self, dest: &Self) -> Steal<Arc<Task>> {
self.stealer.steal_batch_and_pop(&dest.worker)
}
/// Drain (and drop) all tasks that are queued for work.
///
/// This is called when the pool is shutting down.
pub fn drain_tasks(&self) {
pub(crate) fn drain_tasks(&self) {
while self.worker.pop().is_some() {}
}
/// Parks the worker thread.
pub fn park(&self) {
pub(crate) fn park(&self) {
if let Some(park) = unsafe { (*self.park.get()).as_mut() } {
park.park().unwrap();
}
}
/// Parks the worker thread for at most `duration`.
pub fn park_timeout(&self, duration: Duration) {
pub(crate) fn park_timeout(&self, duration: Duration) {
if let Some(park) = unsafe { (*self.park.get()).as_mut() } {
park.park_timeout(duration).unwrap();
}
@@ -228,7 +228,7 @@ impl WorkerEntry {
/// Unparks the worker thread.
#[inline]
pub fn unpark(&self) {
pub(crate) fn unpark(&self) {
if let Some(park) = unsafe { (*self.unpark.get()).as_ref() } {
park.unpark();
}
@@ -238,7 +238,7 @@ impl WorkerEntry {
///
/// Called when the task is being polled for the first time.
#[inline]
pub fn register_task(&self, task: &Arc<Task>) {
pub(crate) fn register_task(&self, task: &Arc<Task>) {
let running_tasks = unsafe { &mut *self.running_tasks.get() };
let key = running_tasks.insert(task.clone());
@@ -249,7 +249,7 @@ impl WorkerEntry {
///
/// Called when the task is completed and was previously registered in this worker.
#[inline]
pub fn unregister_task(&self, task: Arc<Task>) {
pub(crate) fn unregister_task(&self, task: Arc<Task>) {
let running_tasks = unsafe { &mut *self.running_tasks.get() };
running_tasks.remove(task.reg_index.get());
self.drain_remotely_completed_tasks();
@@ -260,7 +260,7 @@ impl WorkerEntry {
/// Called when the task is completed by another worker and was previously registered in this
/// worker.
#[inline]
pub fn remotely_complete_task(&self, task: Arc<Task>) {
pub(crate) fn remotely_complete_task(&self, task: Arc<Task>) {
self.remotely_completed_tasks.push(task);
self.needs_drain.store(true, Release);
}
@@ -268,7 +268,7 @@ impl WorkerEntry {
/// Drops the remaining incomplete tasks and the parker associated with this worker.
///
/// This function is called by the shutdown trigger.
pub fn shutdown(&self) {
pub(crate) fn shutdown(&self) {
self.drain_remotely_completed_tasks();
// Abort all incomplete tasks.
@@ -297,17 +297,17 @@ impl WorkerEntry {
}
#[inline]
pub fn push_internal(&self, task: Arc<Task>) {
pub(crate) fn push_internal(&self, task: Arc<Task>) {
self.worker.push(task);
}
#[inline]
pub fn next_sleeper(&self) -> usize {
pub(crate) fn next_sleeper(&self) -> usize {
unsafe { *self.next_sleeper.get() }
}
#[inline]
pub fn set_next_sleeper(&self, val: usize) {
pub(crate) fn set_next_sleeper(&self, val: usize) {
unsafe {
*self.next_sleeper.get() = val;
}
+3 -3
View File
@@ -58,7 +58,7 @@ const ABA_GUARD_MASK: usize = (1 << (32 - ABA_GUARD_SHIFT)) - 1;
impl Stack {
/// Create a new `Stack` representing the empty state.
pub fn new() -> Stack {
pub(crate) fn new() -> Stack {
let state = AtomicUsize::new(State::new().into());
Stack { state }
}
@@ -71,7 +71,7 @@ impl Stack {
///
/// Returns `Err` if the pool has transitioned to the `TERMINATED` state.
/// When terminated, pushing new entries is no longer permitted.
pub fn push(&self, entries: &[worker::Entry], idx: usize) -> Result<(), ()> {
pub(crate) fn push(&self, entries: &[worker::Entry], idx: usize) -> Result<(), ()> {
let mut state: State = self.state.load(Acquire).into();
debug_assert!(worker::State::from(entries[idx].state.load(Relaxed)).is_pushed());
@@ -113,7 +113,7 @@ impl Stack {
/// Returns the index of the popped worker and the worker's observed state.
///
/// `None` if the stack is empty.
pub fn pop(
pub(crate) fn pop(
&self,
entries: &[worker::Entry],
max_lifecycle: worker::Lifecycle,
+7 -7
View File
@@ -35,15 +35,15 @@ pub(crate) enum Lifecycle {
impl State {
/// Returns true if the worker entry is pushed in the sleeper stack
pub fn is_pushed(self) -> bool {
pub(crate) fn is_pushed(self) -> bool {
self.0 & PUSHED_MASK == PUSHED_MASK
}
pub fn set_pushed(&mut self) {
pub(crate) fn set_pushed(&mut self) {
self.0 |= PUSHED_MASK
}
pub fn is_notified(self) -> bool {
pub(crate) fn is_notified(self) -> bool {
use self::Lifecycle::*;
match self.lifecycle() {
@@ -52,19 +52,19 @@ impl State {
}
}
pub fn lifecycle(self) -> Lifecycle {
pub(crate) fn lifecycle(self) -> Lifecycle {
Lifecycle::from(self.0 & LIFECYCLE_MASK)
}
pub fn set_lifecycle(&mut self, val: Lifecycle) {
pub(crate) fn set_lifecycle(&mut self, val: Lifecycle) {
self.0 = (self.0 & !LIFECYCLE_MASK) | (val as usize)
}
pub fn is_signaled(self) -> bool {
pub(crate) fn is_signaled(self) -> bool {
self.lifecycle() == Lifecycle::Signaled
}
pub fn notify(&mut self) {
pub(crate) fn notify(&mut self) {
use self::Lifecycle::Signaled;
if self.lifecycle() != Signaled {