HydraHook
Direct3D and Core Audio hooking library for Windows
Loading...
Searching...
No Matches
HookActivityTracker Struct Reference

Lock-free tracker for in-flight hook lambda invocations. More...

#include <Engine.h>

Classes

struct  Guard
 RAII guard placed at the top of every hook lambda. More...

Static Public Member Functions

static void shutdown () noexcept
 Sets the shutdown flag so new Guard instances skip callbacks.
static void reset () noexcept
 Clears the shutdown flag so a rehook invokes callbacks again.
static bool drain (DWORD timeout_ms=5000) noexcept
 Spin-waits until every in-flight lambda has returned.

Static Public Attributes

static std::atomic< int32_t > s_active {0}
static std::atomic< bool > s_shutting_down {false}

Detailed Description

Lock-free tracker for in-flight hook lambda invocations.

Allows the engine thread to wait for all render-thread callbacks to complete before unloading the DLL. The hot path is two atomic increments/decrements (lock xadd on x86-64) and one flag load – no mutex, no kernel transition.

Definition at line 173 of file Engine.h.

Member Function Documentation

◆ drain()

bool HookActivityTracker::drain ( DWORD timeout_ms = 5000)
inlinestaticnoexcept

Spin-waits until every in-flight lambda has returned.

Only called once at shutdown, after all hooks have been removed (so no new entries are possible). Yields the time-slice on each iteration to avoid burning a core.

Parameters
timeout_msMaximum time to wait.
Returns
true if drained, false on timeout.

Definition at line 226 of file Engine.h.

References s_active.

Referenced by DestroyEngine(), HydraHookEngineRehook(), and HydraHookEngineUnhook().

◆ reset()

void HookActivityTracker::reset ( )
inlinestaticnoexcept

Clears the shutdown flag so a rehook invokes callbacks again.

Definition at line 211 of file Engine.h.

References s_shutting_down.

Referenced by HydraHookEngineCreate(), and HydraHookEngineRehook().

◆ shutdown()

void HookActivityTracker::shutdown ( )
inlinestaticnoexcept

Sets the shutdown flag so new Guard instances skip callbacks.

Definition at line 205 of file Engine.h.

References s_shutting_down.

Referenced by DestroyEngine().

Member Data Documentation

◆ s_active

std::atomic<int32_t> HookActivityTracker::s_active {0}
inlinestatic

◆ s_shutting_down

std::atomic<bool> HookActivityTracker::s_shutting_down {false}
inlinestatic

Definition at line 176 of file Engine.h.

Referenced by HookActivityTracker::Guard::Guard(), reset(), and shutdown().


The documentation for this struct was generated from the following file: