mirror of
https://github.com/matrix-construct/construct
synced 2025-01-21 12:01:55 +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();
|
construct::console->context.interrupt();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -103,7 +103,7 @@ construct::console::terminate()
|
||||||
construct::console->context.terminate();
|
construct::console->context.terminate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -137,10 +137,10 @@ construct::console::console()
|
||||||
|
|
||||||
void
|
void
|
||||||
construct::console::main()
|
construct::console::main()
|
||||||
try
|
|
||||||
{
|
{
|
||||||
const unwind destruct{[]
|
const unwind dtor{[]
|
||||||
{
|
{
|
||||||
|
assert(construct::console);
|
||||||
construct::console->context.detach();
|
construct::console->context.detach();
|
||||||
delete construct::console;
|
delete construct::console;
|
||||||
construct::console = nullptr;
|
construct::console = nullptr;
|
||||||
|
@ -149,30 +149,22 @@ try
|
||||||
if(!wait_running())
|
if(!wait_running())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ircd::module module{"console"};
|
ircd::module module
|
||||||
this->module = &module;
|
|
||||||
|
|
||||||
if(next_command())
|
|
||||||
{
|
{
|
||||||
while(handle_line())
|
"console"
|
||||||
if(!next_command())
|
};
|
||||||
break;
|
|
||||||
|
|
||||||
if(unlikely(quit_when_done))
|
this->module = &module;
|
||||||
{
|
loop();
|
||||||
static ircd::ios::descriptor descriptor
|
}
|
||||||
{
|
|
||||||
"construct.console.quit"
|
|
||||||
};
|
|
||||||
|
|
||||||
ircd::dispatch
|
void
|
||||||
{
|
construct::console::loop()
|
||||||
descriptor, ios::defer, ircd::quit
|
try
|
||||||
};
|
{
|
||||||
}
|
if(next_command())
|
||||||
|
if(handle_queued())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
show_message(); do
|
show_message(); do
|
||||||
{
|
{
|
||||||
|
@ -194,6 +186,39 @@ catch(const std::exception &e)
|
||||||
"The console session has ended: %s", e.what()
|
"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
|
bool
|
||||||
construct::console::handle_line()
|
construct::console::handle_line()
|
||||||
|
@ -513,10 +538,6 @@ construct::console::on_runlevel(const enum ircd::run::level &runlevel)
|
||||||
switch(runlevel)
|
switch(runlevel)
|
||||||
{
|
{
|
||||||
case ircd::run::level::QUIT:
|
case ircd::run::level::QUIT:
|
||||||
if(terminate())
|
|
||||||
context.join();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ircd::run::level::HALT:
|
case ircd::run::level::HALT:
|
||||||
terminate();
|
terminate();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -41,6 +41,8 @@ struct construct::console
|
||||||
bool cmd__watch();
|
bool cmd__watch();
|
||||||
int handle_line_bymodule();
|
int handle_line_bymodule();
|
||||||
bool handle_line();
|
bool handle_line();
|
||||||
|
bool handle_queued();
|
||||||
|
void loop();
|
||||||
void main();
|
void main();
|
||||||
|
|
||||||
console();
|
console();
|
||||||
|
|
|
@ -190,7 +190,6 @@ void
|
||||||
construct::handle_quit()
|
construct::handle_quit()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
console::terminate();
|
|
||||||
ircd::quit();
|
ircd::quit();
|
||||||
}
|
}
|
||||||
catch(const std::exception &e)
|
catch(const std::exception &e)
|
||||||
|
|
Loading…
Add table
Reference in a new issue