mirror of
https://github.com/matrix-construct/construct
synced 2024-11-12 04:51:08 +01:00
ircd::run: Rename level IDLE to LOAD; minor reorg.
This commit is contained in:
parent
59ee170817
commit
c815de3621
5 changed files with 47 additions and 50 deletions
|
@ -239,7 +239,7 @@ noexcept try
|
|||
|
||||
// This object registers a callback for a specific event in libircd; the
|
||||
// closure is called from the main context (#1) running ircd::main().
|
||||
// after libircd is ready for service in runlevel IDLE but before entering
|
||||
// after libircd is ready for service in runlevel LOAD but before entering
|
||||
// runlevel RUN. It is called again immediately after entering runlevel
|
||||
// QUIT, but before any functionality of libircd destructs. This cues us
|
||||
// to start and stop the homeserver.
|
||||
|
@ -251,7 +251,7 @@ noexcept try
|
|||
|
||||
// 2 This branch is taken the first time this function is called,
|
||||
// and not taken the second time.
|
||||
if(level == ircd::run::level::IDLE && !context && !nomatrix)
|
||||
if(level == ircd::run::level::LOAD && !context && !nomatrix)
|
||||
{
|
||||
// 3 Launch the homeserver context (asynchronous).
|
||||
context = { "matrix", ircd::context::POST, homeserver };
|
||||
|
|
|
@ -36,6 +36,43 @@ namespace ircd::run
|
|||
extern const enum level &chadburn;
|
||||
}
|
||||
|
||||
/// The run::level allows all observers to know the coarse state of IRCd and to
|
||||
/// react accordingly. This can be used by the embedder of libircd to know
|
||||
/// when it's safe to use or delete libircd resources. It is also used
|
||||
/// similarly by the library and its modules. Only one runlevel is active at
|
||||
/// any time.
|
||||
///
|
||||
/// * HALT is the off mode. Nothing is/will be running in libircd until
|
||||
/// an invocation of ircd::init();
|
||||
///
|
||||
/// * READY is the state after calling ircd::init(). Leaving READY is done with
|
||||
/// the user either calling their ios.run() to start executing tasks or calling
|
||||
/// ircd::quit() to HALT again.
|
||||
///
|
||||
/// * START indicates the daemon is executing its startup procedures. Leaving
|
||||
/// the START state occurs internally when there is success or a fatal error.
|
||||
///
|
||||
/// * RUN is the service mode. Full client and application functionality exists
|
||||
/// in this mode. Leaving the RUN mode is done with ircd::quit();
|
||||
///
|
||||
/// * QUIT indicates the daemon is executing the shutdown procedures. This
|
||||
/// will eventually return back to the HALT state.
|
||||
///
|
||||
/// * FAULT is a special mode indicating something really bad. The exact
|
||||
/// details of this mode are ambiguous. Users do not have to handle this.
|
||||
///
|
||||
enum class ircd::run::level
|
||||
:int
|
||||
{
|
||||
FAULT = -1, ///< Unrecoverable fault.
|
||||
HALT = 0, ///< x <-- IRCd Powered off.
|
||||
READY = 1, ///< | | Ready for user to run ios event loop.
|
||||
START = 2, ///< | | Starting internal subsystems.
|
||||
LOAD = 3, ///< | | Load user application.
|
||||
RUN = 4, ///< O | IRCd in service.
|
||||
QUIT = 5, ///< --> ^ Clean shutdown in progress.
|
||||
};
|
||||
|
||||
/// An instance of this class registers itself to be called back when
|
||||
/// the ircd::run::level has changed. The context for this callback differs
|
||||
/// based on the level argument; not all invocations are on an ircd::ctx, etc.
|
||||
|
@ -88,43 +125,3 @@ struct ircd::run::changed
|
|||
changed() noexcept;
|
||||
~changed() noexcept;
|
||||
};
|
||||
|
||||
/// The run::level allows all observers to know the coarse state of IRCd and to
|
||||
/// react accordingly. This can be used by the embedder of libircd to know
|
||||
/// when it's safe to use or delete libircd resources. It is also used
|
||||
/// similarly by the library and its modules. Only one runlevel is active at
|
||||
/// any time.
|
||||
///
|
||||
/// * HALT is the off mode. Nothing is/will be running in libircd until
|
||||
/// an invocation of ircd::init();
|
||||
///
|
||||
/// * READY is the state after calling ircd::init(). Leaving READY is done with
|
||||
/// the user either calling their ios.run() to start executing tasks or calling
|
||||
/// ircd::quit() to HALT again.
|
||||
///
|
||||
/// * START indicates the daemon is executing its startup procedures. Leaving
|
||||
/// the START state occurs internally when there is success or a fatal error.
|
||||
///
|
||||
/// * IDLE indicates the library is ready for use. The user can load their
|
||||
/// application in this mode before transitioning to RUN.
|
||||
///
|
||||
/// * RUN is the service mode. Full client and application functionality exists
|
||||
/// in this mode. Leaving the RUN mode is done with ircd::quit();
|
||||
///
|
||||
/// * QUIT indicates the daemon is executing the shutdown procedures. This
|
||||
/// will eventually return back to the HALT state.
|
||||
///
|
||||
/// * FAULT is a special mode indicating something really bad. The exact
|
||||
/// details of this mode are ambiguous. Users do not have to handle this.
|
||||
///
|
||||
enum class ircd::run::level
|
||||
:int
|
||||
{
|
||||
FAULT = -1, ///< Unrecoverable fault.
|
||||
HALT = 0, ///< x <-- IRCd Powered off.
|
||||
READY = 1, ///< | | Ready for user to run ios event loop.
|
||||
START = 2, ///< | | Starting internal subsystems.
|
||||
IDLE = 3, ///< | | Ready for user to load application.
|
||||
RUN = 4, ///< O | IRCd in service.
|
||||
QUIT = 5, ///< --> ^ Clean shutdown in progress.
|
||||
};
|
||||
|
|
|
@ -200,7 +200,7 @@ noexcept
|
|||
return true;
|
||||
}
|
||||
|
||||
case run::level::IDLE:
|
||||
case run::level::LOAD:
|
||||
case run::level::START:
|
||||
{
|
||||
ctx::terminate(*main_context);
|
||||
|
@ -251,7 +251,7 @@ noexcept
|
|||
case run::level::QUIT:
|
||||
return;
|
||||
|
||||
case run::level::IDLE:
|
||||
case run::level::LOAD:
|
||||
case run::level::RUN:
|
||||
break;
|
||||
}
|
||||
|
@ -318,9 +318,9 @@ noexcept try
|
|||
ircd::run::set(run::level::QUIT);
|
||||
}};
|
||||
|
||||
// IRCd will now transition to the IDLE state allowing library user's to
|
||||
// IRCd will now transition to the LOAD state allowing library user's to
|
||||
// load their applications using the run::changed callback.
|
||||
run::set(run::level::IDLE);
|
||||
run::set(run::level::LOAD);
|
||||
|
||||
// IRCd will now transition to the RUN state indicating full functionality.
|
||||
run::set(run::level::RUN);
|
||||
|
|
|
@ -123,7 +123,7 @@ try
|
|||
{
|
||||
case level::HALT: break;
|
||||
case level::QUIT: break;
|
||||
case level::IDLE: throw;
|
||||
case level::LOAD: throw;
|
||||
default: throw;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ catch(const std::exception &e)
|
|||
{
|
||||
switch(new_level)
|
||||
{
|
||||
case level::IDLE: throw;
|
||||
case level::LOAD: throw;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ ircd::run::reflect(const enum run::level &level)
|
|||
case level::HALT: return "HALT";
|
||||
case level::READY: return "READY";
|
||||
case level::START: return "START";
|
||||
case level::IDLE: return "IDLE";
|
||||
case level::LOAD: return "LOAD";
|
||||
case level::RUN: return "RUN";
|
||||
case level::QUIT: return "QUIT";
|
||||
case level::FAULT: return "FAULT";
|
||||
|
|
|
@ -180,7 +180,7 @@ void
|
|||
ircd::m::on_load()
|
||||
try
|
||||
{
|
||||
assert(ircd::run::level == run::level::IDLE);
|
||||
assert(ircd::run::level == run::level::LOAD);
|
||||
}
|
||||
catch(const m::error &e)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue