Invert meaning of operator bool for CUDA stream and event#199
Conversation
|
I see also that there actually already sort of existed a cudaEvent_t wrapper... just hidden inside the future helper. I'll try to unify the event wrapper added in #190 with the existing one in a separate PR. |
There was a problem hiding this comment.
Pull request overview
This PR aligns the boolean conversion semantics of CUDA stream/event wrappers with typical C++ “valid object == true” expectations (and with the GHEX_C_STRUCT / GHEX_C_MANAGED_STRUCT behavior referenced in the linked #190 discussion), by making moved-from objects evaluate to false.
Changes:
- Invert
operator bool()forghex::device::streamandghex::device::cuda_eventto returntruewhen the wrapper is usable (not moved-from). - Update the
event_poolinternal assertion to match the newcuda_eventboolean semantics.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| include/ghex/device/cuda/stream.hpp | stream::operator bool() now reports validity (!m_moved). |
| include/ghex/device/cuda/event.hpp | cuda_event::operator bool() now reports validity (!m_moved). |
| include/ghex/device/cuda/event_pool.hpp | Adjust assertion in get_event() to reflect the new cuda_event truthiness. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I'll go ahead and merge this together with #200. |
This was a leftover from #190. See #190 (comment).