Program Listing for File CqReactor.hpp

Return to documentation for file (BackendLibfabric/CqReactor.hpp)

#ifndef NETIO3BACKEND_BACKENDLIBFABRIC_CQREACTOR_HPP
#define NETIO3BACKEND_BACKENDLIBFABRIC_CQREACTOR_HPP

#include <cstdint>

#include <rdma/fabric.h>

#include "netio3-backend/Netio3Backend.hpp"
#include "ReceiveEndpoint.hpp"
#include "SendEndpointBuffered.hpp"
#include "SendEndpointZeroCopy.hpp"

namespace netio3::libfabric {
  template<typename EndpointType>
  concept SendEndpointConcept = std::is_same_v<EndpointType, SendEndpointBuffered> ||
                                 std::is_same_v<EndpointType, SendEndpointZeroCopy>;

  class CqReactor
  {
  public:
    CqReactor(fid_fabric* fabric, OnDataCb on_data_cb);

    template<SendEndpointConcept EndpointType>
    [[nodiscard]] std::vector<std::uint64_t> on_send_cq_event(EndpointType& endpoint) const;

    void on_recv_cq_event(ReceiveEndpoint& endpoint) const;

  private:
    fid_fabric* m_fabric{
      nullptr};
    OnDataCb m_on_data_cb{};
  };
}  // namespace netio3::libfabric

#endif  // NETIO3BACKEND_BACKENDLIBFABRIC_CQREACTOR_HPP