template <typename ReturnType, typename... Args>
class AtomicHook
Defined at line 71 of file ../../third_party/abseil-cpp/absl/base/internal/atomic_hook.h
`AtomicHook` is a helper class, templatized on a raw function pointer type,
for implementing Abseil customization hooks. It is a callable object that
dispatches to the registered hook. Objects of type `AtomicHook` must have
static or thread storage duration.
A default constructed object performs a no-op (and returns a default
constructed object) if no hook has been registered.
Hooks can be pre-registered via constant initialization, for example:
ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES static AtomicHook
<void
(*)()>
my_hook(DefaultAction);
and then changed at runtime via a call to `Store()`.
Reads and writes guarantee memory_order_acquire/memory_order_release
semantics.
Public Methods
void AtomicHook<ReturnType (*)(Args...)> ()
Constructs an object that by default performs a no-op (and
returns a default constructed object) when no hook as been registered.
Defined at line 78 of file ../../third_party/abseil-cpp/absl/base/internal/atomic_hook.h
void AtomicHook<ReturnType (*)(Args...)> (FnPtr default_fn)
Defined at line 83 of file ../../third_party/abseil-cpp/absl/base/internal/atomic_hook.h
void Store (FnPtr fn)
Stores the provided function pointer as the value for this hook.
This is intended to be called once. Multiple calls are legal only if the
same function pointer is provided for each call. The store is implemented
as a memory_order_release operation, and read accesses are implemented as
memory_order_acquire.
Defined at line 107 of file ../../third_party/abseil-cpp/absl/base/internal/atomic_hook.h
template <typename... CallArgs>
ReturnType operator() (CallArgs &&... args)
Invokes the registered callback. If no callback has yet been registered, a
default-constructed object of the appropriate type is returned instead.
Defined at line 116 of file ../../third_party/abseil-cpp/absl/base/internal/atomic_hook.h
FnPtr Load ()
Returns the registered callback, or nullptr if none has been registered.
Useful if client code needs to conditionalize behavior based on whether a
callback was registered.
Note that atomic_hook.Load()() and atomic_hook() have different semantics:
operator()() will perform a no-op if no callback was registered, while
Load()() will dereference a null function pointer. Prefer operator()() to
Load()() unless you must conditionalize behavior on whether a hook was
registered.
Defined at line 129 of file ../../third_party/abseil-cpp/absl/base/internal/atomic_hook.h