kkraus14 commented on code in PR #37040:
URL: https://github.com/apache/arrow/pull/37040#discussion_r1293773997
##########
cpp/src/arrow/device.h:
##########
@@ -102,26 +103,40 @@ class ARROW_EXPORT Device : public
std::enable_shared_from_this<Device>,
/// \brief EXPERIMENTAL: An object that provides event/stream sync primitives
///
- ///
+ /// This class is thread-safe.
class ARROW_EXPORT SyncEvent {
public:
virtual ~SyncEvent() = default;
/// @brief Block until sync event is completed.
- ///
- /// Should be a no-op for CPU devices.
- virtual Status wait() = 0;
+ Status wait() {
+ const std::lock_guard<std::mutex> lock(mx_);
+ wait_internal();
+ }
/// @brief Make the provided stream wait on the sync event.
///
/// Tells the provided stream that it should wait until the
/// synchronization event is completed without blocking the CPU.
/// @param stream Should be appropriate for the underlying device
- virtual Status stream_wait(void* stream) = 0;
+ Status stream_wait(void* stream) {
+ const std::lock_guard<std::mutex> lock(mx_);
+ stream_wait_internal(stream);
+ }
Review Comment:
Do we need to lock on these two APIs? I imagine it makes them non-trivially
more expensive, especially in the case where `wait()` could be a no-op?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]