0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd:Ⓜ️:vm: Checkpoint phase-as-class skeleton.

This commit is contained in:
Jason Volk 2018-06-11 22:45:37 -07:00
parent cc0072df0e
commit 912562f469
3 changed files with 22 additions and 3 deletions

View file

@ -247,8 +247,11 @@ struct ircd::m::vm::phase
:instance_list<phase>
{
string_view name;
std::function<void (eval &)> function;
phase(const string_view &name);
void operator()(eval &);
phase(const string_view &name, decltype(function) = nullptr);
};
struct ircd::m::vm::accepted

View file

@ -616,12 +616,27 @@ decltype(ircd::util::instance_list<ircd::m::vm::phase>::list)
ircd::util::instance_list<ircd::m::vm::phase>::list
{};
ircd::m::vm::phase::phase(const string_view &name)
ircd::m::vm::phase::phase(const string_view &name,
decltype(function) function)
:name{name}
,function{std::move(function)}
{
}
void
ircd::m::vm::phase::operator()(eval &eval)
{
auto theirs(eval.phase);
eval.phase = this;
const unwind _{[&eval, &theirs]
{
eval.phase = theirs;
}};
if(likely(function))
function(eval);
}
//
// accepted
//

View file

@ -7395,6 +7395,7 @@ console_cmd__vm__eval(opt &out, const string_view &line)
out << std::setw(9) << std::right << eval->id
<< " | " << std::setw(4) << std::right << id(*eval->ctx)
<< " | " << std::setw(4) << std::right << eval->sequence
<< " | " << std::setw(16) << std::left << (eval->phase? eval->phase->name : "")
<< " | " << std::setw(64) << std::left << eval->event_id
;