1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

feat(RM,allocators): use atomic counters math abstraction

This commit is contained in:
drrtuy
2025-03-17 14:32:50 +00:00
parent b14613a66b
commit 729db829a2
4 changed files with 25 additions and 13 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.
@ -30,6 +31,16 @@ Boost has something in interprocess::ipcdetail, but it doesn't have 64-bit API's
namespace atomicops
{
// Atomic operations for atomic<int64_t> references
inline int64_t atomicAddRef(std::atomic<int64_t>& ref, int64_t val)
{
return ref.fetch_add(val, std::memory_order_relaxed);
}
inline int64_t atomicSubRef(std::atomic<int64_t>& ref, int64_t val)
{
return ref.fetch_sub(val, std::memory_order_relaxed);
}
// Returns the resulting, incremented value
template <typename T>
inline T atomicInc(volatile T* mem)