|
|
@ -8,7 +8,7 @@ use crate::sync::Mutex;
|
|
|
|
/// # Examples
|
|
|
|
/// # Examples
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
/// # fn main() { async_std::task::block_on(async {
|
|
|
|
/// # async_std::task::block_on(async {
|
|
|
|
/// #
|
|
|
|
/// #
|
|
|
|
/// use async_std::sync::{Arc, Barrier};
|
|
|
|
/// use async_std::sync::{Arc, Barrier};
|
|
|
|
/// use async_std::task;
|
|
|
|
/// use async_std::task;
|
|
|
@ -30,7 +30,6 @@ use crate::sync::Mutex;
|
|
|
|
/// handle.await;
|
|
|
|
/// handle.await;
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
/// # });
|
|
|
|
/// # });
|
|
|
|
/// # }
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[cfg(feature = "unstable")]
|
|
|
|
#[cfg(feature = "unstable")]
|
|
|
|
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
|
|
|
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
|
|
@ -120,7 +119,7 @@ impl Barrier {
|
|
|
|
/// # Examples
|
|
|
|
/// # Examples
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
/// # fn main() { async_std::task::block_on(async {
|
|
|
|
/// # async_std::task::block_on(async {
|
|
|
|
/// #
|
|
|
|
/// #
|
|
|
|
/// use async_std::sync::{Arc, Barrier};
|
|
|
|
/// use async_std::sync::{Arc, Barrier};
|
|
|
|
/// use async_std::task;
|
|
|
|
/// use async_std::task;
|
|
|
@ -142,7 +141,6 @@ impl Barrier {
|
|
|
|
/// handle.await;
|
|
|
|
/// handle.await;
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
/// # });
|
|
|
|
/// # });
|
|
|
|
/// # }
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
pub async fn wait(&self) -> BarrierWaitResult {
|
|
|
|
pub async fn wait(&self) -> BarrierWaitResult {
|
|
|
|
let mut lock = self.state.lock().await;
|
|
|
|
let mut lock = self.state.lock().await;
|
|
|
@ -190,7 +188,7 @@ impl BarrierWaitResult {
|
|
|
|
/// # Examples
|
|
|
|
/// # Examples
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
/// # fn main() { async_std::task::block_on(async {
|
|
|
|
/// # async_std::task::block_on(async {
|
|
|
|
/// #
|
|
|
|
/// #
|
|
|
|
/// use async_std::sync::Barrier;
|
|
|
|
/// use async_std::sync::Barrier;
|
|
|
|
///
|
|
|
|
///
|
|
|
@ -198,7 +196,6 @@ impl BarrierWaitResult {
|
|
|
|
/// let barrier_wait_result = barrier.wait().await;
|
|
|
|
/// let barrier_wait_result = barrier.wait().await;
|
|
|
|
/// println!("{:?}", barrier_wait_result.is_leader());
|
|
|
|
/// println!("{:?}", barrier_wait_result.is_leader());
|
|
|
|
/// # });
|
|
|
|
/// # });
|
|
|
|
/// # }
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
pub fn is_leader(&self) -> bool {
|
|
|
|
pub fn is_leader(&self) -> bool {
|
|
|
|
self.0
|
|
|
|
self.0
|
|
|
|