0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 14:38:57 +02:00

ircd:Ⓜ️🪝 Add accounting for hook calls; site/hook current call count.

This commit is contained in:
Jason Volk 2019-04-18 21:42:47 -07:00
parent 02b835eb2b
commit c7a872c67a
2 changed files with 21 additions and 0 deletions

View file

@ -41,6 +41,7 @@ struct ircd::m::hook::base
bool registered {false};
size_t matchers {0};
size_t calls {0};
size_t calling {0};
string_view site_name() const;
site *find_site() const;
@ -62,6 +63,8 @@ struct ircd::m::hook::base::site
std::set<base *> hooks;
size_t matchers {0};
bool exceptions {true};
size_t calls {0};
size_t calling {0};
friend class base;
string_view name() const;
@ -154,7 +157,15 @@ ircd::m::hook::site<data>::call(hook<data> &hfn,
data d)
try
{
// stats for site
++calls;
const scope_count site_calling{calling};
// stats for hook
++hfn.calls;
const scope_count hook_calling{hfn.calling};
// call hook
hfn.function(event, d);
}
catch(const std::exception &e)

View file

@ -5555,6 +5555,8 @@ noexcept
auto *const site(find_site());
assert(site != nullptr);
assert(site->calling == 0);
assert(calling == 0);
site->del(*this);
}
@ -5773,7 +5775,15 @@ ircd::m::hook::site<void>::call(hook<void> &hfn,
const event &event)
try
{
// stats for site
++calls;
const scope_count site_calling{calling};
// stats for hook
++hfn.calls;
const scope_count hook_calling{hfn.calling};
// call hook
hfn.function(event);
}
catch(const std::exception &e)