rtpsw commented on code in PR #36094:
URL: https://github.com/apache/arrow/pull/36094#discussion_r1238357290
##########
cpp/src/arrow/acero/asof_join_node.cc:
##########
@@ -364,21 +364,16 @@ struct MemoStore {
std::swap(index_, memo.index_);
#endif
std::swap(no_future_, memo.no_future_);
- current_time_ =
memo.current_time_.exchange(static_cast<OnType>(current_time_));
+ std::swap(current_time_, memo.current_time_);
entries_.swap(memo.entries_);
future_entries_.swap(memo.future_entries_);
times_.swap(memo.times_);
}
- // Updates the current time to `ts` if it is less. A different thread may
win the race
- // to update the current time to more than `ts` but not to less. Returns
whether the
- // current time was changed from its value at the beginning of this
invocation.
+ // Updates the current time to `ts` if it is less. Returns true if updated.
bool UpdateTime(OnType ts) {
- OnType prev_time = current_time_;
- bool update = prev_time < ts;
- while (prev_time < ts && !current_time_.compare_exchange_weak(prev_time,
ts)) {
- // intentionally empty - standard CAS loop
- }
+ bool update = current_time_ < ts;
+ if (update) current_time_ = ts;
Review Comment:
The method still needs to return a Boolean, so we can't remove the `bool
update` line, but we can replace the if-statement.
--
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]