Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
tmccombs committed Oct 28, 2019
1 parent 80aece0 commit b20d048
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/sync/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct WaitTimeoutResult(bool);
/// not
impl WaitTimeoutResult {
/// Returns `true` if the wait was known to have timed out.
pub fn timed_out(&self) -> bool {
pub fn timed_out(self) -> bool {
self.0
}
}
Expand Down Expand Up @@ -62,6 +62,12 @@ pub struct Condvar {
blocked: std::sync::Mutex<Slab<Option<Waker>>>,
}

impl Default for Condvar {
fn default() -> Self {
Condvar::new()
}
}

impl Condvar {
/// Creates a new condition variable
///
Expand Down Expand Up @@ -111,6 +117,7 @@ impl Condvar {
/// }
/// # }) }
/// ```
#[allow(clippy::needless_lifetimes)]
pub async fn wait<'a, T>(&self, guard: MutexGuard<'a, T>) -> MutexGuard<'a, T> {
let mutex = guard_lock(&guard);

Expand Down Expand Up @@ -161,6 +168,7 @@ impl Condvar {
/// # }) }
/// ```
#[cfg(feature = "unstable")]
#[allow(clippy::needless_lifetimes)]
pub async fn wait_until<'a, T, F>(
&self,
mut guard: MutexGuard<'a, T>,
Expand Down Expand Up @@ -213,6 +221,7 @@ impl Condvar {
/// #
/// # }) }
/// ```
#[allow(clippy::needless_lifetimes)]
pub async fn wait_timeout<'a, T>(
&self,
guard: MutexGuard<'a, T>,
Expand Down
4 changes: 2 additions & 2 deletions tests/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn notify_all() {
let mut tasks: Vec<JoinHandle<()>> = Vec::new();
let pair = Arc::new((Mutex::new(0u32), Condvar::new()));

for i in 0..10 {
for _ in 0..10 {
let pair = pair.clone();
tasks.push(task::spawn(async move {
let (m, c) = &*pair;
Expand All @@ -57,6 +57,6 @@ fn notify_all() {
t.await;
}
let count = m.lock().await;
assert!(*count == 11);
assert_eq!(11, *count);
})
}

0 comments on commit b20d048

Please sign in to comment.