Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: runtime/vm/atomic_test.cc

Issue 1580813003: Use atomic operations to increment/decrement memory usage counts as multiple threads could be alloc… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: self-code-review Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/atomic_test.cc
diff --git a/runtime/vm/atomic_test.cc b/runtime/vm/atomic_test.cc
index 2e327a52235817c8b444046a8b9a1625b3a88b80..db9be229f76252105474269783cd0aa7ca824b12 100644
--- a/runtime/vm/atomic_test.cc
+++ b/runtime/vm/atomic_test.cc
@@ -26,6 +26,22 @@ UNIT_TEST_CASE(FetchAndDecrement) {
}
+UNIT_TEST_CASE(FetchAndIncrementBy) {
+ intptr_t v = 42;
+ EXPECT_EQ(static_cast<uintptr_t>(42),
+ AtomicOperations::FetchAndIncrementBy(&v, 100));
+ EXPECT_EQ(static_cast<intptr_t>(142), v);
+}
+
+
+UNIT_TEST_CASE(FetchAndDecrementBy) {
+ intptr_t v = 42;
+ EXPECT_EQ(static_cast<uintptr_t>(42),
+ AtomicOperations::FetchAndDecrementBy(&v, 41));
+ EXPECT_EQ(static_cast<intptr_t>(1), v);
+}
+
+
UNIT_TEST_CASE(LoadRelaxed) {
uword v = 42;
EXPECT_EQ(static_cast<uword>(42), AtomicOperations::LoadRelaxed(&v));
« no previous file with comments | « runtime/vm/atomic_macos.h ('k') | runtime/vm/atomic_win.h » ('j') | runtime/vm/pages.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698