0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

ircd::allocator::je: Create and move relevant into actual allocator::je namespace.

This commit is contained in:
Jason Volk 2020-05-10 18:35:52 -07:00
parent bab494cafd
commit 708bba4bf9

View file

@ -14,13 +14,13 @@
#define IRCD_ALLOCATOR_JEMALLOC #define IRCD_ALLOCATOR_JEMALLOC
#endif #endif
namespace ircd::allocator namespace ircd::allocator::je
{ {
static std::function<void (std::ostream &, const string_view &)> je_stats_callback; static std::function<void (std::ostream &, const string_view &)> stats_callback;
static void je_stats_handler(void *, const char *); static void stats_handler(void *, const char *);
extern info::versions je_malloc_version_api; extern info::versions malloc_version_api;
extern info::versions je_malloc_version_abi; extern info::versions malloc_version_abi;
} }
#if defined(IRCD_ALLOCATOR_USE_JEMALLOC) #if defined(IRCD_ALLOCATOR_USE_JEMALLOC)
@ -33,8 +33,8 @@ malloc_conf
}; };
#endif #endif
decltype(ircd::allocator::je_malloc_version_api) decltype(ircd::allocator::je::malloc_version_api)
ircd::allocator::je_malloc_version_api ircd::allocator::je::malloc_version_api
{ {
"jemalloc", info::versions::API, 0, "jemalloc", info::versions::API, 0,
#ifdef HAVE_JEMALLOC_H #ifdef HAVE_JEMALLOC_H
@ -47,8 +47,8 @@ ircd::allocator::je_malloc_version_api
#endif #endif
}; };
decltype(ircd::allocator::je_malloc_version_abi) decltype(ircd::allocator::je::malloc_version_abi)
ircd::allocator::je_malloc_version_abi ircd::allocator::je::malloc_version_abi
{ {
"jemalloc", info::versions::ABI, //TODO: get this "jemalloc", info::versions::ABI, //TODO: get this
}; };
@ -98,8 +98,8 @@ ircd::allocator::set(const string_view &key_,
#endif #endif
void void
ircd::allocator::je_stats_handler(void *const ptr, ircd::allocator::je::stats_handler(void *const ptr,
const char *const msg) const char *const msg)
try try
{ {
auto &out auto &out
@ -107,7 +107,7 @@ try
*reinterpret_cast<std::stringstream *>(ptr) *reinterpret_cast<std::stringstream *>(ptr)
}; };
je_stats_callback(out, msg); stats_callback(out, msg);
} }
catch(const std::bad_function_call &) catch(const std::bad_function_call &)
{ {
@ -122,7 +122,7 @@ ircd::allocator::info(const mutable_buffer &buf)
std::stringstream out; std::stringstream out;
pubsetbuf(out, buf); pubsetbuf(out, buf);
je_stats_callback = [] je::stats_callback = []
(auto &out, const string_view &msg) (auto &out, const string_view &msg)
{ {
out << msg; out << msg;
@ -133,7 +133,7 @@ ircd::allocator::info(const mutable_buffer &buf)
"" ""
}; };
malloc_stats_print(je_stats_handler, &out, opts); malloc_stats_print(je::stats_handler, &out, opts);
out << std::endl; out << std::endl;
return view(out, buf); return view(out, buf);
} }