1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

fix(DEC): MCOL-5602 fixing potentially endless loop in DEC (#3049)

This commit is contained in:
drrtuy
2023-12-05 17:39:24 +02:00
committed by GitHub
parent 63b032e3fd
commit 1d416bc6ed
3 changed files with 73 additions and 79 deletions

View File

@ -22,6 +22,7 @@
#include <unistd.h>
#include <stdint.h>
#include <sched.h>
#include <atomic>
/*
This is an attempt to wrap the differneces between Windows and Linux around atomic ops.
@ -92,4 +93,15 @@ inline void atomicYield()
sched_yield();
}
// This f assumes decrement is smaller than minuend.
template <typename T>
inline void atomicSubstitute(typename std::atomic<T>& minuend, T decrement)
{
T expected = minuend.load();
do
{
expected = minuend.load();
} while (!minuend.compare_exchange_weak(expected, expected - decrement));
}
} // namespace atomicops