Skip to main content

ibverbs_rs/multi_channel/ops/
scoped_ops.rs

1use crate::channel::TransportResult;
2use crate::channel::{PollingScope, ScopedPendingWork};
3use crate::ibverbs::work::SendWorkRequest;
4use crate::multi_channel::MultiChannel;
5use crate::multi_channel::work_request::*;
6
7impl<'scope, 'env> PollingScope<'scope, 'env, MultiChannel> {
8    /// Posts sends to multiple peers, returning handles for manual polling.
9    pub fn post_scatter_send<'wr, I>(
10        &mut self,
11        wrs: I,
12    ) -> TransportResult<Vec<ScopedPendingWork<'scope>>>
13    where
14        I: IntoIterator<Item = PeerSendWorkRequest<'wr, 'env>>,
15        'env: 'wr,
16    {
17        wrs.into_iter().map(|wr| self.post_send(wr)).collect()
18    }
19
20    /// Posts RDMA writes to multiple peers, returning handles for manual polling.
21    pub fn post_scatter_write<'wr, I>(
22        &mut self,
23        wrs: I,
24    ) -> TransportResult<Vec<ScopedPendingWork<'scope>>>
25    where
26        I: IntoIterator<Item = PeerWriteWorkRequest<'wr, 'env>>,
27        'env: 'wr,
28    {
29        wrs.into_iter().map(|wr| self.post_write(wr)).collect()
30    }
31
32    /// Posts receives from multiple peers, returning handles for manual polling.
33    pub fn post_gather_receive<'wr, I>(
34        &mut self,
35        wrs: I,
36    ) -> TransportResult<Vec<ScopedPendingWork<'scope>>>
37    where
38        I: IntoIterator<Item = PeerReceiveWorkRequest<'wr, 'env>>,
39        'env: 'wr,
40    {
41        wrs.into_iter().map(|wr| self.post_receive(wr)).collect()
42    }
43
44    /// Posts RDMA reads from multiple peers, returning handles for manual polling.
45    pub fn post_gather_read<'wr, I>(
46        &mut self,
47        wrs: I,
48    ) -> TransportResult<Vec<ScopedPendingWork<'scope>>>
49    where
50        I: IntoIterator<Item = PeerReadWorkRequest<'wr, 'env>>,
51        'env: 'wr,
52    {
53        wrs.into_iter().map(|wr| self.post_read(wr)).collect()
54    }
55
56    /// Posts the same send to multiple peers, returning handles for manual polling.
57    pub fn post_multicast_send<'wr, I>(
58        &mut self,
59        peers: I,
60        wr: SendWorkRequest<'wr, 'env>,
61    ) -> TransportResult<Vec<ScopedPendingWork<'scope>>>
62    where
63        I: IntoIterator<Item = usize>,
64        'env: 'wr,
65    {
66        peers
67            .into_iter()
68            .map(|peer| self.post_send(PeerSendWorkRequest::from_wr(peer, wr.clone())))
69            .collect()
70    }
71}