sandbox
Loading...
Searching...
No Matches
cache.hpp
1
// SPDX-License-Identifier: MIT
2
#ifndef LIBSBX_MEMORY_CACHE_HPP_
3
#define LIBSBX_MEMORY_CACHE_HPP_
4
5
#include <new>
6
7
namespace
sbx::memory {
8
9
struct
cacheline
{
10
inline
static
constexpr
auto
size = std::hardware_constructive_interference_size;
11
};
// struct cacheline
12
13
template
<
typename
Type>
14
struct
cacheline_aligned
{
15
alignas
(2u * cacheline::size) Type data;
16
17
template
<
typename
... Args>
18
cacheline_aligned
(Args&&... args)
19
: data{std::forward<Args>(args)...} { }
20
21
operator
Type&() {
22
return
data;
23
}
24
25
operator
const
Type&()
const
{
26
return
data;
27
}
28
29
};
// struct cacheline_aligned
30
31
}
// namespace sbx::memory
32
33
#endif
// LIBSBX_MEMORY_CACHE_HPP_
sbx::memory::cacheline_aligned
Definition:
cache.hpp:14
sbx::memory::cacheline
Definition:
cache.hpp:9
libsbx-memory
libsbx
memory
cache.hpp
Generated by
1.9.5