Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stricter checks, implement Debug where needed #7

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
//! assert_eq!(v, 42);
//! });
//! ```
#![warn(missing_docs, missing_debug_implementations, unreachable_pub)]

mod loom_exports;

use std::future::Future;
Expand All @@ -83,6 +85,7 @@ use loom_exports::sync::Mutex;
use pin_project_lite::pin_project;

/// An object that can receive or send notifications.
#[derive(Debug)]
pub struct Event {
wait_set: WaitSet,
}
Expand Down Expand Up @@ -220,6 +223,7 @@ unsafe impl Send for Notifier {}
unsafe impl Sync for Notifier {}

/// A future that can be `await`ed until a predicate is satisfied.
#[derive(Debug)]
pub struct WaitUntil<'a, F: FnMut() -> Option<T>, T> {
state: WaitUntilState,
predicate: F,
Expand Down Expand Up @@ -391,7 +395,7 @@ impl<'a, F: FnMut() -> Option<T>, T> Future for WaitUntil<'a, F, T> {
}

/// State of the `WaitUntil` future.
#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
enum WaitUntilState {
Idle,
Polled(NonNull<Notifier>),
Expand Down Expand Up @@ -449,6 +453,7 @@ where
///
/// The set wraps a Mutex-protected list of notifiers and manages a flag for
/// fast assessment of list emptiness.
#[derive(Debug)]
struct WaitSet {
list: Mutex<List>,
is_empty: AtomicBool,
Expand Down Expand Up @@ -689,7 +694,7 @@ impl Default for WaitSet {
}
}

#[derive(Default)]
#[derive(Default, Debug)]
struct List {
front: Option<NonNull<Notifier>>,
back: Option<NonNull<Notifier>>,
Expand Down