1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#include "descriptor.hpp"
#ifdef WITH_GENERIC_EPOCH_BASED
#include <xenium/reclamation/generic_epoch_based.hpp>
#include <tao/config/value.hpp>
inline std::string to_string(xenium::reclamation::region_extension v) {
switch (v) {
case xenium::reclamation::region_extension::eager: return "eager";
case xenium::reclamation::region_extension::lazy: return "lazy";
case xenium::reclamation::region_extension::none: return "none";
default: assert(false); return "<invalid region_extension>";
}
}
template <>
struct descriptor<xenium::reclamation::scan::all_threads> {
static tao::json::value generate() {
return {{"type", "all_threads"}};
}
};
template <>
struct descriptor<xenium::reclamation::scan::one_thread> {
static tao::json::value generate() {
return {{"type", "one_thread"}};
}
};
template <unsigned N>
struct descriptor<xenium::reclamation::scan::n_threads<N>> {
static tao::json::value generate() {
return {
{"type", "n_threads"},
{"n", N}
};
}
};
template <>
struct descriptor<xenium::reclamation::abandon::never> {
static tao::json::value generate() {
return {{"type", "never"}};
}
};
template <>
struct descriptor<xenium::reclamation::abandon::always> {
static tao::json::value generate() {
return {{"type", "always"}};
}
};
template <size_t Threshold>
struct descriptor<xenium::reclamation::abandon::when_exceeds_threshold<Threshold>> {
static tao::json::value generate() {
return {
{"type", "when_exceeds_threshold"},
{"threshold", Threshold}
};
}
};
template <class Traits>
struct descriptor<xenium::reclamation::generic_epoch_based<Traits>> {
static tao::json::value generate() {
return {
{"type", "generic_epoch_based"},
{"scan_frequency", Traits::scan_frequency},
{"scan_strategy", descriptor<typename Traits::scan_strategy>::generate()},
{"abandon_strategy", descriptor<typename Traits::abandon_strategy>::generate()},
{"region_extension", to_string(Traits::region_extension_type)}
};
}
};
#endif
#ifdef WITH_QUIESCENT_STATE_BASED
#include <xenium/reclamation/quiescent_state_based.hpp>
template <>
struct descriptor<xenium::reclamation::quiescent_state_based> {
static tao::json::value generate() {
return {{"type", "quiescent_state_based"}};
}
};
#endif
#ifdef WITH_HAZARD_POINTER
#include <xenium/reclamation/hazard_pointer.hpp>
template <class Traits>
struct descriptor<xenium::reclamation::hazard_pointer<Traits>> {
static tao::json::value generate() {
return {
{"type", "hazard_pointer"},
{"allocation_strategy", descriptor<typename Traits::allocation_strategy>::generate()}
};
}
};
template <size_t K, size_t A, size_t B>
struct descriptor<xenium::reclamation::hp_allocation::dynamic_strategy<K, A, B>> {
static tao::json::value generate() {
return {
{"type", "dynamic"},
{"K", K},
{"A", A},
{"B", B}
};
}
};
template <size_t K, size_t A, size_t B>
struct descriptor<xenium::reclamation::hp_allocation::static_strategy<K, A, B>> {
static tao::json::value generate() {
return {
{"type", "static"},
{"A", A},
{"K", K},
{"B", B},
};
}
};
#endif
|