summaryrefslogtreecommitdiffstats
path: root/vespamalloc
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-10-10 13:59:06 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-10-10 14:40:15 +0000
commit16bdf92863957c505697e5badd8d965df8471035 (patch)
tree67ca36b21142eb14a9c0ccbde49d5cfc34c3422d /vespamalloc
parent3126b4608e11a85b7b58eaf99f4d48a1fb5bacfb (diff)
Unify code style
Diffstat (limited to 'vespamalloc')
-rw-r--r--vespamalloc/src/vespamalloc/malloc/allocchunk.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/vespamalloc/src/vespamalloc/malloc/allocchunk.cpp b/vespamalloc/src/vespamalloc/malloc/allocchunk.cpp
index 818a10541ce..fc89a3c3d8e 100644
--- a/vespamalloc/src/vespamalloc/malloc/allocchunk.cpp
+++ b/vespamalloc/src/vespamalloc/malloc/allocchunk.cpp
@@ -3,26 +3,29 @@
namespace vespamalloc {
-
-void AFListBase::linkInList(AtomicHeadPtr & head, AFListBase * list) noexcept
+void
+AFListBase::linkInList(AtomicHeadPtr & head, AFListBase * list) noexcept
{
AFListBase * tail;
for (tail = list; tail->_next != nullptr ;tail = tail->_next) { }
linkIn(head, list, tail);
}
-void AFListBase::linkIn(AtomicHeadPtr & head, AFListBase * csl, AFListBase * tail) noexcept
+void
+AFListBase::linkIn(AtomicHeadPtr & head, AFListBase * csl, AFListBase * tail) noexcept
{
HeadPtr oldHead = head.load(std::memory_order_relaxed);
HeadPtr newHead(csl, oldHead._tag + 1);
tail->_next = static_cast<AFListBase *>(oldHead._ptr);
+ // linkIn/linkOut performs a release/aquire pair
while ( __builtin_expect(! head.compare_exchange_weak(oldHead, newHead, std::memory_order_release, std::memory_order_relaxed), false) ) {
- newHead._tag = oldHead._tag + 1;
+ newHead._tag = oldHead._tag + 1;
tail->_next = static_cast<AFListBase *>(oldHead._ptr);
}
}
-AFListBase * AFListBase::linkOut(AtomicHeadPtr & head) noexcept
+AFListBase *
+AFListBase::linkOut(AtomicHeadPtr & head) noexcept
{
HeadPtr oldHead = head.load(std::memory_order_relaxed);
auto *csl = static_cast<AFListBase *>(oldHead._ptr);
@@ -30,6 +33,7 @@ AFListBase * AFListBase::linkOut(AtomicHeadPtr & head) noexcept
return nullptr;
}
HeadPtr newHead(csl->_next, oldHead._tag + 1);
+ // linkIn/linkOut performs a release/aquire pair
while ( __builtin_expect(! head.compare_exchange_weak(oldHead, newHead, std::memory_order_acquire, std::memory_order_relaxed), false) ) {
csl = static_cast<AFListBase *>(oldHead._ptr);
if (csl == nullptr) {