summaryrefslogtreecommitdiff
path: root/include/my_atomic_wrapper.h
diff options
context:
space:
mode:
authorKrunal Bauskar <mysqlonarm@gmail.com>2021-03-29 11:51:00 +0800
committerMarko Mäkelä <marko.makela@mariadb.com>2021-03-29 16:15:28 +0300
commit0f6f72965bc5743961725ec3bf7b541130427bc7 (patch)
treeeed9634ed4e636f0c70815793052b94950656cfd /include/my_atomic_wrapper.h
parent8048831a5be604f3a8bb4caf0b3c7cd92b7b3c2d (diff)
downloadmariadb-git-0f6f72965bc5743961725ec3bf7b541130427bc7.tar.gz
MDEV-25281: Switch to use non-atomic (vs atomic) distributed counter to
track page-access counter As part of MDEV-21212, n_page_gets that is meant to track page access, is ported to use distributed counter that default uses atomic sub-counters. n_page_gets originally was a non-atomic counter that represented an approximate value of pages tracked. Using the said analogy it doesn't need to be an atomic distributed counter. This patch introduces an interface that allows distributed counter to be used with atomic and non-atomic sub-counter (through template) and also port n_page_gets to use non-atomic distributed counter using the said updated interface.
Diffstat (limited to 'include/my_atomic_wrapper.h')
-rw-r--r--include/my_atomic_wrapper.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/my_atomic_wrapper.h b/include/my_atomic_wrapper.h
index c574fba4a8e..106c8e3c15c 100644
--- a/include/my_atomic_wrapper.h
+++ b/include/my_atomic_wrapper.h
@@ -45,6 +45,7 @@ public:
Type operator=(const Type val)
{ m.store(val, std::memory_order_relaxed); return val; }
Type operator=(const Atomic_relaxed<Type> &rhs) { return *this= Type{rhs}; }
+ Type operator+=(const Type i) { return fetch_add(i); }
Type fetch_add(const Type i, std::memory_order o= std::memory_order_relaxed)
{ return m.fetch_add(i, o); }
Type fetch_sub(const Type i, std::memory_order o= std::memory_order_relaxed)