This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 8806416603d70b14ef0432461fb035a39a5074e0
Author: Alexey Serbin <[email protected]>
AuthorDate: Wed Nov 6 19:45:01 2024 -0800

    [client] remove chromium Atomics from C++ client
    
    This patch replaces chromium-derived atomics with STL-based ones,
    but otherwise it doesn't contain any functional modifications.
    
    Change-Id: I0d25fb40d95b12c98bbb82ee0e489e325db1d433
    Reviewed-on: http://gerrit.cloudera.org:8080/22037
    Tested-by: Alexey Serbin <[email protected]>
    Reviewed-by: Mahesh Reddy <[email protected]>
    Reviewed-by: Yifan Zhang <[email protected]>
---
 src/kudu/client/client-internal.cc |  5 +++--
 src/kudu/client/client-internal.h  |  4 ++--
 src/kudu/client/client-test.cc     | 20 +++++++-------------
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/src/kudu/client/client-internal.cc 
b/src/kudu/client/client-internal.cc
index d57595ee1..9a2237e53 100644
--- a/src/kudu/client/client-internal.cc
+++ b/src/kudu/client/client-internal.cc
@@ -63,6 +63,7 @@
 #include "kudu/security/cert.h"
 #include "kudu/security/tls_context.h"
 #include "kudu/util/async_util.h"
+#include "kudu/util/atomic-utils.h"
 #include "kudu/util/logging.h"
 #include "kudu/util/net/dns_resolver.h"
 #include "kudu/util/net/net_util.h"
@@ -968,11 +969,11 @@ KuduClient::Data::txn_manager_proxy() const {
 }
 
 uint64_t KuduClient::Data::GetLatestObservedTimestamp() const {
-  return latest_observed_timestamp_.Load();
+  return latest_observed_timestamp_.load(std::memory_order_relaxed);
 }
 
 void KuduClient::Data::UpdateLatestObservedTimestamp(uint64_t timestamp) {
-  latest_observed_timestamp_.StoreMax(timestamp);
+  AtomicStoreMax(latest_observed_timestamp_, timestamp);
 }
 
 } // namespace client
diff --git a/src/kudu/client/client-internal.h 
b/src/kudu/client/client-internal.h
index 6efcd78b3..2bf217794 100644
--- a/src/kudu/client/client-internal.h
+++ b/src/kudu/client/client-internal.h
@@ -16,6 +16,7 @@
 // under the License.
 #pragma once
 
+#include <atomic>
 #include <cstdint>
 #include <functional>
 #include <map>
@@ -34,7 +35,6 @@
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/rpc/rpc_controller.h"
 #include "kudu/rpc/user_credentials.h"
-#include "kudu/util/atomic.h"
 #include "kudu/util/locks.h"
 #include "kudu/util/monotime.h"
 #include "kudu/util/net/net_util.h"
@@ -362,7 +362,7 @@ class KuduClient::Data {
   // in-depth explanation of why this is needed and how it works.
   mutable simple_spinlock leader_master_lock_;
 
-  AtomicInt<uint64_t> latest_observed_timestamp_;
+  std::atomic<uint64_t> latest_observed_timestamp_;
 
  private:
   DISALLOW_COPY_AND_ASSIGN(Data);
diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc
index d6e118879..9f4162230 100644
--- a/src/kudu/client/client-test.cc
+++ b/src/kudu/client/client-test.cc
@@ -78,7 +78,6 @@
 #include "kudu/common/wire_protocol.h"
 #include "kudu/common/wire_protocol.pb.h"
 #include "kudu/consensus/metadata.pb.h"
-#include "kudu/gutil/atomicops.h"
 #include "kudu/gutil/casts.h"
 #include "kudu/gutil/integral_types.h"
 #include "kudu/gutil/map-util.h"
@@ -206,10 +205,6 @@ 
METRIC_DECLARE_histogram(handler_latency_kudu_master_MasterService_GetTableSchem
 
METRIC_DECLARE_histogram(handler_latency_kudu_master_MasterService_GetTabletLocations);
 
METRIC_DECLARE_histogram(handler_latency_kudu_tserver_TabletServerService_Scan);
 
-using base::subtle::Atomic32;
-using base::subtle::NoBarrier_AtomicIncrement;
-using base::subtle::NoBarrier_Load;
-using base::subtle::NoBarrier_Store;
 using google::protobuf::util::MessageDifferencer;
 using kudu::cluster::InternalMiniCluster;
 using kudu::cluster::InternalMiniClusterOptions;
@@ -6100,16 +6095,16 @@ TEST_F(ClientTest, TestMasterLookupPermits) {
 namespace {
 class DLSCallback : public KuduStatusCallback {
  public:
-  explicit DLSCallback(Atomic32* i) : i_(i) {
+  explicit DLSCallback(atomic<uint32_t>* i) : i_(i) {
   }
 
   void Run(const Status& s) override {
     CHECK_OK(s);
-    NoBarrier_AtomicIncrement(i_, 1);
+    i_->fetch_add(1, std::memory_order_relaxed);
     delete this;
   }
  private:
-  Atomic32* const i_;
+  atomic<uint32_t>* const i_;
 };
 
 // Returns col1 value of first row.
@@ -6214,9 +6209,8 @@ TEST_F(ClientTest, TestDeadlockSimulation) {
   }
 
   // Run async calls - one thread updates sequentially, another in reverse.
-  Atomic32 ctr1, ctr2;
-  NoBarrier_Store(&ctr1, 0);
-  NoBarrier_Store(&ctr2, 0);
+  atomic<uint32_t> ctr1(0);
+  atomic<uint32_t> ctr2(0);
   for (int i = 0; i < kNumSessions; ++i) {
     // The callbacks are freed after they are invoked.
     fwd_sessions[i]->FlushAsync(new DLSCallback(&ctr1));
@@ -6226,8 +6220,8 @@ TEST_F(ClientTest, TestDeadlockSimulation) {
   // Spin while waiting for ops to complete.
   int lctr1, lctr2, prev1 = 0, prev2 = 0;
   do {
-    lctr1 = NoBarrier_Load(&ctr1);
-    lctr2 = NoBarrier_Load(&ctr2);
+    lctr1 = ctr1.load(std::memory_order_relaxed);
+    lctr2 = ctr2.load(std::memory_order_relaxed);
     // Display progress in 10% increments.
     if (prev1 == 0 || lctr1 + lctr2 - prev1 - prev2 > kNumSessions / 10) {
       LOG(INFO) << "# updates: " << lctr1 << " fwd, " << lctr2 << " rev";

Reply via email to