Skip to content

Commit 90683f7

Browse files
committed
Improve clarity via docs and more explicit constructors
1 parent 1f7b67f commit 90683f7

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

cpp/include/raft/mr/notifying_adaptor.hpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ namespace raft::mr {
2121
*/
2222
class notifier {
2323
private:
24+
/**
25+
* @brief Activity flag.
26+
*
27+
* Note, the meaning is somewhat inverted:
28+
* - TRUE (flag is set) means "no allocations/deallocations have occurred"
29+
* - FALSE (flag is clear) means "one or more allocations/deallocations have occurred"
30+
*
31+
* This is hidden behind notify() and wait() to avoid confusion.
32+
*/
2433
// NB: using `cuda::std` in place of `std`,
2534
// because this may happen to be included in pre-C++20 code downstream.
26-
cuda::std::atomic_flag flag_; // Note, meaning of the flag is inverted
35+
cuda::std::atomic_flag flag_;
2736

2837
public:
2938
notifier() noexcept { flag_.test_and_set(cuda::std::memory_order_relaxed); }
@@ -67,11 +76,14 @@ class notifying_adaptor : public cuda::forward_property<notifying_adaptor<Upstre
6776
std::shared_ptr<notifier> notifier_;
6877

6978
public:
70-
// Prevent recursive concept satisfaction when Upstream is a __basic_any type (GCC C++20).
71-
template <typename U, std::enable_if_t<std::is_same_v<std::decay_t<U>, Upstream>, int> = 0>
72-
explicit notifying_adaptor(U&& upstream,
73-
std::shared_ptr<notifier> n = std::make_shared<notifier>())
74-
: upstream_(std::forward<U>(upstream)), notifier_(std::move(n))
79+
/**
80+
* @brief Construct a new notifying adaptor.
81+
*
82+
* @param upstream An upstream resource or reference to wrap.
83+
* @param notifier A shared notifier to use (pass it to a consumer as well).
84+
*/
85+
notifying_adaptor(Upstream upstream, std::shared_ptr<notifier> notifier)
86+
: upstream_(std::move(upstream)), notifier_(std::move(notifier))
7587
{
7688
}
7789

@@ -129,7 +141,4 @@ class notifying_adaptor : public cuda::forward_property<notifying_adaptor<Upstre
129141
[[nodiscard]] auto upstream_resource() const noexcept -> Upstream const& { return upstream_; }
130142
};
131143

132-
template <typename Upstream>
133-
notifying_adaptor(Upstream, std::shared_ptr<notifier>) -> notifying_adaptor<Upstream>;
134-
135144
} // namespace raft::mr

0 commit comments

Comments
 (0)