Executes registered hook callbacks at defined points with mutex protection, logging errors without disrupting flow. Reuse for extensible event‑driven extensions in C++ services.
// Source: https://github.com/ionclaw-org/ionclaw | License: MIT | Copyright 2026 IonClaw
// Provided via justclaw.it.com; keep this notice with the code.
#include "ionclaw/agent/HookRunner.hpp"
#include "spdlog/spdlog.h"
namespace ionclaw
{
namespace agent
{
void HookRunner::run(HookPoint point, HookContext &ctx) const
{
// copy callbacks under lock, then invoke outside to avoid holding mutex during arbitrary code
std::vector<HookCallback> callbacks;
{
std::lock_guard<std::mutex> lock(mutex);
auto it = hooks.find(point);
if (it == hooks.end())
{
return;
}
callbacks = it->second;
}
for (const auto &callback : callbacks)
{
try
{
callback(ctx);
}
catch (cons
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key