mirror of
https://github.com/matrix-construct/construct
synced 2025-01-02 19:04:17 +01:00
construct::console: Improve main sequence; extension module unload related.
This commit is contained in:
parent
85a509f004
commit
6da0291562
3 changed files with 52 additions and 30 deletions
|
@ -92,7 +92,7 @@ construct::console::interrupt()
|
|||
construct::console->context.interrupt();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -103,7 +103,7 @@ construct::console::terminate()
|
|||
construct::console->context.terminate();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -137,10 +137,10 @@ construct::console::console()
|
|||
|
||||
void
|
||||
construct::console::main()
|
||||
try
|
||||
{
|
||||
const unwind destruct{[]
|
||||
const unwind dtor{[]
|
||||
{
|
||||
assert(construct::console);
|
||||
construct::console->context.detach();
|
||||
delete construct::console;
|
||||
construct::console = nullptr;
|
||||
|
@ -149,30 +149,22 @@ try
|
|||
if(!wait_running())
|
||||
return;
|
||||
|
||||
ircd::module module{"console"};
|
||||
this->module = &module;
|
||||
|
||||
if(next_command())
|
||||
ircd::module module
|
||||
{
|
||||
while(handle_line())
|
||||
if(!next_command())
|
||||
break;
|
||||
"console"
|
||||
};
|
||||
|
||||
if(unlikely(quit_when_done))
|
||||
{
|
||||
static ircd::ios::descriptor descriptor
|
||||
{
|
||||
"construct.console.quit"
|
||||
};
|
||||
this->module = &module;
|
||||
loop();
|
||||
}
|
||||
|
||||
ircd::dispatch
|
||||
{
|
||||
descriptor, ios::defer, ircd::quit
|
||||
};
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
void
|
||||
construct::console::loop()
|
||||
try
|
||||
{
|
||||
if(next_command())
|
||||
if(handle_queued())
|
||||
return;
|
||||
|
||||
show_message(); do
|
||||
{
|
||||
|
@ -194,6 +186,39 @@ catch(const std::exception &e)
|
|||
"The console session has ended: %s", e.what()
|
||||
};
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
log::debug
|
||||
{
|
||||
"The console session has terminated."
|
||||
};
|
||||
}
|
||||
|
||||
bool
|
||||
construct::console::handle_queued()
|
||||
{
|
||||
while(handle_line())
|
||||
if(!next_command())
|
||||
break;
|
||||
|
||||
if(!quit_when_done)
|
||||
return true;
|
||||
|
||||
if(run::level != run::level::RUN)
|
||||
return true;
|
||||
|
||||
static ircd::ios::descriptor descriptor
|
||||
{
|
||||
"construct.console.quit"
|
||||
};
|
||||
|
||||
ircd::dispatch
|
||||
{
|
||||
descriptor, ios::defer, ircd::quit
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
construct::console::handle_line()
|
||||
|
@ -513,10 +538,6 @@ construct::console::on_runlevel(const enum ircd::run::level &runlevel)
|
|||
switch(runlevel)
|
||||
{
|
||||
case ircd::run::level::QUIT:
|
||||
if(terminate())
|
||||
context.join();
|
||||
break;
|
||||
|
||||
case ircd::run::level::HALT:
|
||||
terminate();
|
||||
break;
|
||||
|
|
|
@ -41,6 +41,8 @@ struct construct::console
|
|||
bool cmd__watch();
|
||||
int handle_line_bymodule();
|
||||
bool handle_line();
|
||||
bool handle_queued();
|
||||
void loop();
|
||||
void main();
|
||||
|
||||
console();
|
||||
|
|
|
@ -190,7 +190,6 @@ void
|
|||
construct::handle_quit()
|
||||
try
|
||||
{
|
||||
console::terminate();
|
||||
ircd::quit();
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
|
|
Loading…
Reference in a new issue