#include <cstdlib>
#include <new>
浏览源代码.
◆ CACHELINE_SIZE
#define CACHELINE_SIZE 64 |
◆ cyber_likely
#define cyber_likely |
( |
|
x | ) |
(x) |
◆ cyber_unlikely
#define cyber_unlikely |
( |
|
x | ) |
(x) |
◆ DEFINE_TYPE_TRAIT
#define DEFINE_TYPE_TRAIT |
( |
|
name, |
|
|
|
func |
|
) |
| |
值: template <typename T> \
struct name { \
template <typename Class> \
static constexpr bool Test(decltype(&Class::func)*) { \
return true; \
} \
template <typename> \
static constexpr bool Test(...) { \
return false; \
} \
\
static constexpr bool value = Test<T>(nullptr); \
}; \
\
template <typename T> \
constexpr bool name<T>::value;
在文件 macros.h 第 35 行定义.
37 { \
38 template <typename Class> \
39 static constexpr bool Test(decltype(&Class::func)*) { \
40 return true; \
41 } \
42 template <typename> \
43 static constexpr bool Test(...) { \
44 return false; \
45 } \
46 \
47 static constexpr bool value = Test<T>(nullptr); \
48 }; \
49 \
50 template <typename T> \
51 constexpr bool name<T>::value;
◆ eprosima
#define eprosima eprosima_wrap |
◆ CheckedCalloc()
void * CheckedCalloc |
( |
size_t |
num, |
|
|
size_t |
size |
|
) |
| |
|
inline |
在文件 macros.h 第 69 行定义.
69 {
70 void* ptr = std::calloc(num, size);
71 if (!ptr) {
72 throw std::bad_alloc();
73 }
74 return ptr;
75}
◆ CheckedMalloc()
void * CheckedMalloc |
( |
size_t |
size | ) |
|
|
inline |
在文件 macros.h 第 61 行定义.
61 {
62 void* ptr = std::malloc(size);
63 if (!ptr) {
64 throw std::bad_alloc();
65 }
66 return ptr;
67}
◆ cpu_relax()
在文件 macros.h 第 53 行定义.
53 {
54#if defined(__aarch64__)
55 asm volatile("yield" ::: "memory");
56#else
57 asm volatile("rep; nop" ::: "memory");
58#endif
59}