RDMA++
Loading...
Searching...
No Matches
cq.h
1#pragma once
2
3#include <array>
4#include <memory>
5#include <vector>
6
7#include <infiniband/verbs.h>
8
9#include "rdmapp/device.h"
10#include "rdmapp/error.h"
11
12#include "rdmapp/detail/noncopyable.h"
13
14namespace rdmapp {
15
16class qp;
17
22class cq : public noncopyable {
23 std::shared_ptr<device> device_;
24 struct ibv_cq *cq_;
25 friend class qp;
26
27public:
34 cq(std::shared_ptr<device> device, size_t num_cqe = 128);
35
45 bool poll(struct ibv_wc &wc);
46
57 size_t poll(std::vector<struct ibv_wc> &wc_vec);
58 template <class It> size_t poll(It wc, int count) {
59 int rc = ::ibv_poll_cq(cq_, count, wc);
60 if (rc < 0) {
61 throw_with("failed to poll cq: %s (rc=%d)", strerror(rc), rc);
62 }
63 return rc;
64 }
65 template <int N> size_t poll(std::array<struct ibv_wc, N> &wc_array) {
66 return poll(&wc_array[0], N);
67 }
68 ~cq();
69};
70
71} // namespace rdmapp
This class is an abstraction of a Completion Queue.
Definition cq.h:22
bool poll(struct ibv_wc &wc)
Poll the completion queue.
Definition cq.cc:23
This class is an abstraction of an Infiniband device.
Definition device.h:48
Definition noncopyable.h:5
This class is an abstraction of an Infiniband Queue Pair.
Definition qp.h:50