pub struct TracingCondvar(_);
Expand description

Wrapper around std::sync::Condvar.

Allows TracingMutexGuard to be used with a Condvar. Unlike other structs in this module, this wrapper does not add any additional dependency tracking or other overhead on top of the primitive it wraps. All dependency tracking happens through the mutexes itself.

Panics

This struct does not add any panics over the base implementation of Condvar, but panics due to dependency tracking may poison associated mutexes.

Examples

use std::sync::Arc;
use std::thread;

use tracing_mutex::stdsync::{TracingCondvar, TracingMutex};

let pair = Arc::new((TracingMutex::new(false), TracingCondvar::new()));
let pair2 = Arc::clone(&pair);

// Spawn a thread that will unlock the condvar
thread::spawn(move || {
    let (lock, condvar) = &*pair2;
    *lock.lock().unwrap() = true;
    condvar.notify_one();
});

// Wait until the thread unlocks the condvar
let (lock, condvar) = &*pair;
let guard = lock.lock().unwrap();
let guard = condvar.wait_while(guard, |started| !*started).unwrap();

// Guard should read true now
assert!(*guard);

Implementations

Creates a new condition variable which is ready to be waited on and notified.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.