A callback registered with Context::OnDestroyed(), tied to a C++ object's lifetime.
When an armed guard is destroyed before its context goes away, it removes the callback, so the callback never runs:
class LevelCache {
public:
: guard_(ctx.OnDestroyed([this] { Clear(); })) {}
void Clear();
};
JavaScript execution environment for a page.
Definition Context.h:263
A callback registered with Context::OnDestroyed(), tied to a C++ object's lifetime.
Definition Context.h:111
To keep the callback for as long as the context lives instead, call Release().
Destroying a guard after its context went away does nothing (the callback already ran).
- Note
- Destroying or move-assigning over an armed guard removes the callback, so do it on the Renderer's thread. To give up a guard on another thread, call Release().
- Note
- operator bool only says whether the guard is armed. It never reflects whether the callback ran or the context is still alive.