tag_probe.h
1 
5 #pragma once
6 
7 #include <atomic>
8 #include <memory>
9 #include <optional>
10 
11 #include <ucp/api/ucp.h>
12 #include <ucxx/tag_probe_builder.h>
13 #include <ucxx/typedefs.h>
14 
15 namespace ucxx {
16 
17 namespace detail {
18 class ConstructorFactory;
19 }
20 
21 // Forward declaration for friend access
22 class RequestTag;
23 class TagProbeInfo;
24 
31 class TagRecvInfo {
32  public:
33  const Tag senderTag;
34  const size_t length;
35 
40 
47  explicit TagRecvInfo(const ucp_tag_recv_info_t& info);
48 };
49 
65 class TagProbeInfo {
66  public:
67  TagProbeInfo(const TagProbeInfo&) = delete;
68  TagProbeInfo& operator=(TagProbeInfo const&) = delete;
69  TagProbeInfo(TagProbeInfo&& o) = delete;
70  TagProbeInfo& operator=(TagProbeInfo&& o) = delete;
71 
72  ~TagProbeInfo();
73 
79  bool isMatched() const;
80 
87  const TagRecvInfo& getInfo() const;
88 
95  ucp_tag_message_h getHandle() const;
96 
107  ucp_tag_message_h releaseHandle() const;
108 
109  private:
110  const bool _matched{false};
111  const std::optional<TagRecvInfo> _info{
112  std::nullopt};
113  const ucp_tag_message_h _handle{
114  nullptr};
116  mutable std::atomic<bool> _consumed{false};
117 
124  void consume() const;
125 
139  TagProbeInfo() = default;
140 
158  TagProbeInfo(const ucp_tag_recv_info_t& info, ucp_tag_message_h handle);
159 
160  // Allow internal construction without exposing factory functions.
161  friend class detail::ConstructorFactory;
162 
163  // Allow RequestTag to consume the handle
164  friend class RequestTag;
165 };
166 
167 } // namespace ucxx
Information about probed tag message.
Definition: tag_probe.h:65
ucp_tag_message_h releaseHandle() const
Release the message handle.
bool isMatched() const
Check if a message was matched.
ucp_tag_message_h getHandle() const
Get the message handle.
const TagRecvInfo & getInfo() const
Get tag receive information.
Information about probed tag message.
Definition: tag_probe.h:31
TagRecvInfo(const ucp_tag_recv_info_t &info)
Construct a TagRecvInfo object from a UCP tag receive info structure.
TagRecvInfo()
Default constructor for TagRecvInfo.
Definition: tag_probe.h:39
const size_t length
The size of the received data.
Definition: tag_probe.h:34
const Tag senderTag
Sender tag.
Definition: tag_probe.h:33
Definition: address.h:16
Tag
Strong type for a UCP tag.
Definition: typedefs.h:66