0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd::util: Use allocator::node for instance_list instances.

This commit is contained in:
Jason Volk 2019-04-16 20:48:00 -07:00
parent 7c6c60960f
commit 4038973297
8 changed files with 82 additions and 20 deletions

View file

@ -33,10 +33,12 @@ namespace ircd::util
template<class T>
struct ircd::util::instance_list
{
static std::list<T *> list;
static ircd::allocator::node<T *> allocator;
static std::list<T *, typename ircd::allocator::node<T *>::allocator> list;
protected:
typename decltype(list)::iterator it;
uint8_t _node[56];
instance_list();
instance_list(instance_list &&) noexcept;
@ -48,28 +50,25 @@ struct ircd::util::instance_list
template<class T>
ircd::util::instance_list<T>::instance_list()
:it
{
list.emplace(end(list), static_cast<T *>(this))
allocator.next = reinterpret_cast<T **>(_node);
it = list.emplace(end(list), static_cast<T *>(this));
}
{}
template<class T>
ircd::util::instance_list<T>::instance_list(instance_list &&other)
noexcept
:it
{
list.emplace(end(list), static_cast<T *>(this))
allocator.next = reinterpret_cast<T **>(_node);
it = list.emplace(end(list), static_cast<T *>(this));
}
{}
template<class T>
ircd::util::instance_list<T>::instance_list(const instance_list &other)
:it
{
list.emplace(end(list), static_cast<T *>(this))
allocator.next = reinterpret_cast<T **>(_node);
it = list.emplace(end(list), static_cast<T *>(this));
}
{}
template<class T>
ircd::util::instance_list<T> &

View file

@ -28,16 +28,23 @@
#endif
/// Instance list linkage for the list of all ctx instances.
template<>
decltype(ircd::util::instance_list<ircd::ctx::ctx>::allocator)
ircd::util::instance_list<ircd::ctx::ctx>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::ctx::ctx>::list)
ircd::util::instance_list<ircd::ctx::ctx>::list
{};
{
allocator
};
/// Public interface linkage for the list of all ctx instances
decltype(ircd::ctx::ctxs)
ircd::ctx::ctxs
{
ctx::ctx::list
reinterpret_cast<const decltype(ircd::ctx::ctxs) &>(ctx::ctx::list)
};
decltype(ircd::ctx::log)

View file

@ -836,10 +836,17 @@ namespace ircd::db
}
// Instance list linkage
template<>
decltype(ircd::util::instance_list<ircd::db::database>::allocator)
ircd::util::instance_list<ircd::db::database>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::db::database>::list)
ircd::util::instance_list<ircd::db::database>::list
{};
{
allocator
};
decltype(ircd::db::default_description)
ircd::db::default_description

View file

@ -124,10 +124,17 @@ ircd::ios::available()
// descriptor
//
template<>
decltype(ircd::util::instance_list<ircd::ios::descriptor>::allocator)
ircd::util::instance_list<ircd::ios::descriptor>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::ios::descriptor>::list)
ircd::util::instance_list<ircd::ios::descriptor>::list
{};
{
allocator
};
decltype(ircd::ios::descriptor::ids)
ircd::ios::descriptor::ids;

View file

@ -311,10 +311,17 @@ ircd::run::level
// run::changed
//
template<>
decltype(ircd::run::changed::allocator)
ircd::util::instance_list<ircd::run::changed>::allocator
{};
template<>
decltype(ircd::run::changed::list)
ircd::util::instance_list<ircd::run::changed>::list
{};
{
allocator
};
decltype(ircd::run::changed::dock)
ircd::run::changed::dock;

View file

@ -53,10 +53,17 @@ struct ircd::log::confs
};
/// Linkage for list of named loggers.
template<>
decltype(ircd::instance_list<ircd::log::log>::allocator)
ircd::instance_list<ircd::log::log>::allocator
{};
template<>
decltype(ircd::instance_list<ircd::log::log>::list)
ircd::instance_list<ircd::log::log>::list
{};
{
allocator
};
decltype(ircd::log::file)
ircd::log::file;

View file

@ -1348,10 +1348,17 @@ ircd::m::vm::reflect(const enum fault &code)
// information and advance the state of IRCd as best as possible.
/// Instance list linkage for all of the evaluations.
template<>
decltype(ircd::util::instance_list<ircd::m::vm::eval>::allocator)
ircd::util::instance_list<ircd::m::vm::eval>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::m::vm::eval>::list)
ircd::util::instance_list<ircd::m::vm::eval>::list
{};
{
allocator
};
decltype(ircd::m::vm::eval::id_ctr)
ircd::m::vm::eval::id_ctr;
@ -5694,10 +5701,17 @@ const
//
/// Instance list linkage for all hooks
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base>::allocator)
ircd::util::instance_list<ircd::m::hook::base>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base>::list)
ircd::util::instance_list<ircd::m::hook::base>::list
{};
{
allocator
};
/// Primary hook ctor
ircd::m::hook::base::base(const json::members &members)
@ -5778,10 +5792,17 @@ catch(const std::out_of_range &e)
//
/// Instance list linkage for all hook sites
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base::site>::allocator)
ircd::util::instance_list<ircd::m::hook::base::site>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base::site>::list)
ircd::util::instance_list<ircd::m::hook::base::site>::list
{};
{
allocator
};
//
// hook::site::site

View file

@ -377,10 +377,17 @@ noexcept
// event
//
template<>
decltype(ircd::util::instance_list<ircd::prof::event>::allocator)
ircd::util::instance_list<ircd::prof::event>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::prof::event>::list)
ircd::util::instance_list<ircd::prof::event>::list
{};
{
allocator
};
//
// event::event