ART: Simplify atomic.h
Prefer std::atomic operations over wrappers in atomic.h. Exceptions
are cases that relate to the Java data memory operations and CAS
operations.
Bug: 71621075
Test: art/test.py --host -j32
Test: art/test.py --target --64 -j4
Change-Id: I9a157e9dede852c1b2aa67d22e3e604a68a9ef1c
diff --git a/runtime/gc/task_processor_test.cc b/runtime/gc/task_processor_test.cc
index 77b40e4..38581ce 100644
--- a/runtime/gc/task_processor_test.cc
+++ b/runtime/gc/task_processor_test.cc
@@ -37,7 +37,7 @@
if (max_recursion_ > 0) {
task_processor_->AddTask(self,
new RecursiveTask(task_processor_, counter_, max_recursion_ - 1));
- counter_->FetchAndAddSequentiallyConsistent(1U);
+ counter_->fetch_add(1U, std::memory_order_seq_cst);
}
}
@@ -54,7 +54,7 @@
}
virtual void Run(Thread* self) OVERRIDE {
task_processor_->RunAllTasks(self);
- done_running_->StoreSequentiallyConsistent(true);
+ done_running_->store(true, std::memory_order_seq_cst);
}
private:
@@ -76,7 +76,7 @@
thread_pool.StartWorkers(self);
ASSERT_FALSE(done_running);
// Wait until all the tasks are done, but since we didn't interrupt, done_running should be 0.
- while (counter.LoadSequentiallyConsistent() != kRecursion) {
+ while (counter.load(std::memory_order_seq_cst) != kRecursion) {
usleep(10);
}
ASSERT_FALSE(done_running);
@@ -84,11 +84,11 @@
thread_pool.Wait(self, true, false);
// After the interrupt and wait, the WorkUntilInterruptedTasktask should have terminated and
// set done_running_ to true.
- ASSERT_TRUE(done_running.LoadSequentiallyConsistent());
+ ASSERT_TRUE(done_running.load(std::memory_order_seq_cst));
// Test that we finish remaining tasks before returning from RunTasksUntilInterrupted.
- counter.StoreSequentiallyConsistent(0);
- done_running.StoreSequentiallyConsistent(false);
+ counter.store(0, std::memory_order_seq_cst);
+ done_running.store(false, std::memory_order_seq_cst);
// Self interrupt before any of the other tasks run, but since we added them we should keep on
// working until all the tasks are completed.
task_processor.Stop(self);
@@ -96,8 +96,8 @@
thread_pool.AddTask(self, new WorkUntilDoneTask(&task_processor, &done_running));
thread_pool.StartWorkers(self);
thread_pool.Wait(self, true, false);
- ASSERT_TRUE(done_running.LoadSequentiallyConsistent());
- ASSERT_EQ(counter.LoadSequentiallyConsistent(), kRecursion);
+ ASSERT_TRUE(done_running.load(std::memory_order_seq_cst));
+ ASSERT_EQ(counter.load(std::memory_order_seq_cst), kRecursion);
}
class TestOrderTask : public HeapTask {
@@ -137,10 +137,10 @@
Atomic<bool> done_running(false);
// Add a task which will wait until interrupted to the thread pool.
thread_pool.AddTask(self, new WorkUntilDoneTask(&task_processor, &done_running));
- ASSERT_FALSE(done_running.LoadSequentiallyConsistent());
+ ASSERT_FALSE(done_running.load(std::memory_order_seq_cst));
thread_pool.StartWorkers(self);
thread_pool.Wait(self, true, false);
- ASSERT_TRUE(done_running.LoadSequentiallyConsistent());
+ ASSERT_TRUE(done_running.load(std::memory_order_seq_cst));
ASSERT_EQ(counter, kNumTasks);
}