@@ -249,20 +249,32 @@ public:
249249 }
250250
251251 // ! @brief Destroys an \c uninitialized_async_buffer, deallocates the buffer in stream order on the stream that
252- // ! was used to create the buffer and destroys the memory resource.
252+ // ! is stored in the buffer and destroys the memory resource.
253+ // ! @param __stream The stream to deallocate the buffer on.
253254 // ! @warning destroy does not destroy any objects that may or may not reside within the buffer. It is the
254255 // ! user's responsibility to ensure that all objects within the buffer have been properly destroyed.
255- _CCCL_HIDE_FROM_ABI void destroy ()
256+ _CCCL_HIDE_FROM_ABI void destroy (::cuda::stream_ref __stream )
256257 {
257258 if (__buf_)
258259 {
259- __mr_.deallocate (__stream_ , __buf_, __get_allocation_size (__count_));
260+ __mr_.deallocate (__stream , __buf_, __get_allocation_size (__count_));
260261 __buf_ = nullptr ;
261262 __count_ = 0 ;
262263 }
264+ // TODO should we make sure we move the mr only once by moving it to the if above?
265+ // It won't work for 0 count buffers, so we would probably need a separate bool to track it
263266 auto __tmp_mr = ::cuda::std::move (__mr_);
264267 }
265268
269+ // ! @brief Destroys an \c uninitialized_async_buffer, deallocates the buffer in stream order on the stream that
270+ // ! is stored in the buffer and destroys the memory resource.
271+ // ! @warning destroy does not destroy any objects that may or may not reside within the buffer. It is the
272+ // ! user's responsibility to ensure that all objects within the buffer have been properly destroyed.
273+ _CCCL_HIDE_FROM_ABI void destroy ()
274+ {
275+ destroy (__stream_);
276+ }
277+
266278 // ! @brief Destroys an \c uninitialized_async_buffer and deallocates the buffer in stream order on the stream
267279 // ! that was used to create the buffer.
268280 // ! @warning The destructor does not destroy any objects that may or may not reside within the buffer. It is the
@@ -331,6 +343,7 @@ public:
331343 }
332344
333345 // ! @brief Returns the stored stream
346+ // ! @note Stream used to allocate the buffer is initially stored in the buffer, but can be changed with `set_stream`
334347 [[nodiscard]] _CCCL_HIDE_FROM_ABI constexpr ::cuda::stream_ref stream () const noexcept
335348 {
336349 return __stream_;
0 commit comments