Program Listing for File ReceiveEndpoint.hpp

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

#ifndef NETIO3BACKEND_BACKENDLIBFABRIC_RECEIVEENDPOINT_HPP
#define NETIO3BACKEND_BACKENDLIBFABRIC_RECEIVEENDPOINT_HPP

#include <functional>

#include <rdma/fi_domain.h>

#include <tracy/Tracy.hpp>

#include "ActiveEndpoint.hpp"
#include "DomainManager.hpp"
#include "Helpers.hpp"
#include "ReceiveBufferManager.hpp"
#include "SharedReceiveContextManager.hpp"
#include "netio3-backend/EventLoop/BaseEventLoop.hpp"
#include "netio3-backend/EventLoop/EventSignalHandle.hpp"
#include "netio3-backend/Netio3Backend.hpp"

namespace netio3::libfabric {
  class ReceiveEndpoint
  {
  public:
    ReceiveEndpoint(ActiveEndpoint& endpoint,
                    ConnectionParametersRecv conn_params,
                    std::optional<SharedReceiveContextManager>& shared_context_manager,
                    DomainManager& domain_manager,
                    BaseEventLoop* event_loop);

    [[nodiscard]] auto operator<=>(const ReceiveEndpoint& other) const
    {
      return m_endpoint.get().get_endpoint().ep <=> other.m_endpoint.get().get_endpoint().ep;
    }

    [[nodiscard]] const ActiveEndpoint& get_active_endpoint() const { return m_endpoint.get(); }
    [[nodiscard]] ActiveEndpoint& get_active_endpoint() { return m_endpoint.get(); }

    void post_buffer(Buffer* buf) {
      ZoneScoped;
      m_buffer_manager_ptr->post_buffer(buf);
    }

  private:
    [[nodiscard]] std::optional<ReceiveBufferManager> create_buffer_manager(
      DomainManager& domain_manager,
      BaseEventLoop* event_loop) const;

    std::reference_wrapper<ActiveEndpoint> m_endpoint;
    ConnectionParametersRecv m_conn_params{};
    std::optional<ReceiveBufferManager> m_buffer_manager{};
    ReceiveBufferManager* m_buffer_manager_ptr{nullptr};
  };
}  // namespace netio3::libfabric

#endif  // NETIO3BACKEND_BACKENDLIBFABRIC_RECEIVEENDPOINT_HPP