mirror of
https://github.com/matrix-construct/construct
synced 2025-03-16 22:41:46 +01:00
ircd: Add mods::init; a subsystem init/fini singleton held by ircd::main().
This commit is contained in:
parent
a4d186b6a1
commit
284bad47e9
3 changed files with 24 additions and 4 deletions
|
@ -121,6 +121,13 @@ bool load(const std::string &name);
|
|||
void autoload();
|
||||
void unload();
|
||||
|
||||
// Initialization and destruction singleton held by ircd::main()
|
||||
struct init
|
||||
{
|
||||
init();
|
||||
~init() noexcept;
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
bool
|
||||
|
|
11
ircd/ircd.cc
11
ircd/ircd.cc
|
@ -85,10 +85,15 @@ void
|
|||
ircd::main()
|
||||
noexcept try
|
||||
{
|
||||
// The user is notified when this function ends; + other cleanup
|
||||
const scope main_exit(&main_exiting);
|
||||
log::debug("IRCd entered main context.");
|
||||
const scope main_exit(&main_exiting); // The user is notified when this function ends
|
||||
|
||||
// These objects are the init()'s and fini()'s for each subsystem. Appearing here ties them
|
||||
// to the main context. Initialization can also occur in ircd::init() if static initialization
|
||||
// and destruction is not possible, but there is no complementary destruction up there.
|
||||
mods::init _mods_;
|
||||
|
||||
// Create IRCd's agency
|
||||
ircd::me = add_client();
|
||||
|
||||
// This is where the configuration is finally evalulated. This must occur
|
||||
|
@ -163,8 +168,6 @@ void
|
|||
ircd::main_exiting()
|
||||
noexcept try
|
||||
{
|
||||
mods::unload();
|
||||
|
||||
if(main_exit_func)
|
||||
{
|
||||
// This function will notify the user of IRCd shutdown. The notification is
|
||||
|
|
|
@ -101,6 +101,16 @@ void load_symbol(mod &mod, const std::string &name, const std::type_index &);
|
|||
} // namespace mods
|
||||
} // namespace ircd
|
||||
|
||||
ircd::mods::init::init()
|
||||
{
|
||||
}
|
||||
|
||||
ircd::mods::init::~init()
|
||||
noexcept
|
||||
{
|
||||
unload();
|
||||
}
|
||||
|
||||
void
|
||||
ircd::mods::unload()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue