Skip to main content

ibverbs_rs/network/ops/
barrier_ops.rs

1use crate::channel::PollingScope;
2use crate::network::Node;
3use crate::network::barrier::BarrierError;
4use std::time::Duration;
5
6impl<'scope, 'env> PollingScope<'scope, 'env, Node> {
7    /// Synchronizes with the given peers, blocking until all have reached the barrier or timeout.
8    pub fn barrier(&mut self, peers: &[usize], timeout: Duration) -> Result<(), BarrierError> {
9        self.inner.barrier(peers, timeout)
10    }
11
12    /// Like [`barrier`](Self::barrier), but skips validation of the peer list.
13    pub fn barrier_unchecked(
14        &mut self,
15        peers: &[usize],
16        timeout: Duration,
17    ) -> Result<(), BarrierError> {
18        self.inner.barrier_unchecked(peers, timeout)
19    }
20}
21
22impl Node {
23    /// Synchronizes with the given peers, blocking until all have reached the barrier or timeout.
24    pub fn barrier(&mut self, peers: &[usize], timeout: Duration) -> Result<(), BarrierError> {
25        self.barrier
26            .barrier(&mut self.multi_channel, peers, timeout)
27    }
28
29    /// Like [`barrier`](Self::barrier), but skips validation of the peer list.
30    pub fn barrier_unchecked(
31        &mut self,
32        peers: &[usize],
33        timeout: Duration,
34    ) -> Result<(), BarrierError> {
35        self.barrier
36            .barrier_unchecked(&mut self.multi_channel, peers, timeout)
37    }
38}