|
perfc 0.11.0
|
Register of counter variants, used for example to facilitate discovery/monitoring. More...
#include <perfc/register.hpp>
Register of counter variants, used for example to facilitate discovery/monitoring.
To define a register for double and std::uint64_t and a std::string as metadata:
| CounterTypes | Specifies which counter types can be registered using the helper perfc::CounterTypes. |
| TMetadata | Specifies the metadata type used to associate each registered counter with. Type requirements: CopyConstructible and CopyAssignable |
| TMutex | The mutex type to use, defaults to std::recursive_mutex. |
Definition at line 257 of file register.hpp.
Classes | |
| struct | Entry |
| Register entry representing the counter and associated metadata. More... | |
Public Types | |
| using | Mutex = TMutex |
| using | MetadataType = TMetadata |
| using | CounterVariant = typename CounterTypes::CounterVariant |
| using | Container = std::vector<Entry> |
| using | LockedContainer = Locked<Container, Mutex> |
| using | LockedContainerConst = Locked<Container const, Mutex> |
Public Member Functions | |||
Access container of counters thread safely | |||
Obtains proxy object to counters that holds lock for synchronized access. Prefer a new nested scope to minimize lock duration: // Minimal scope for Lock()
{
auto counters = register.Lock();
for (auto const& counter : *counters) {
...
}
}
| |||
| LockedContainer | Lock () | ||
| LockedContainerConst | Lock () const | ||
Counter registration | |||
| |||
| ScopedRegistration | Add (CounterVariant counter, MetadataType metadata) | ||
| Add a counter, identified by its address, together with metadata to the register. | |||
| bool | Remove (CounterVariant counter) | ||
| Remove counter from register. | |||
| using perfc::Register< CounterTypes, TMetadata, TMutex >::Container = std::vector<Entry> |
Definition at line 271 of file register.hpp.
| using perfc::Register< CounterTypes, TMetadata, TMutex >::CounterVariant = typename CounterTypes::CounterVariant |
Definition at line 261 of file register.hpp.
| using perfc::Register< CounterTypes, TMetadata, TMutex >::LockedContainer = Locked<Container, Mutex> |
Definition at line 272 of file register.hpp.
| using perfc::Register< CounterTypes, TMetadata, TMutex >::LockedContainerConst = Locked<Container const, Mutex> |
Definition at line 273 of file register.hpp.
| using perfc::Register< CounterTypes, TMetadata, TMutex >::MetadataType = TMetadata |
Definition at line 260 of file register.hpp.
| using perfc::Register< CounterTypes, TMetadata, TMutex >::Mutex = TMutex |
Definition at line 259 of file register.hpp.
|
inlinenodiscard |
Add a counter, identified by its address, together with metadata to the register.
| counter | Pointer to any of the supported counter types. |
| metadata | A metadata object to be associated with counter. |
| std::exception-derived | exceptions originating from standard library. |
Definition at line 328 of file register.hpp.
|
inline |
Definition at line 293 of file register.hpp.
|
inline |
Definition at line 297 of file register.hpp.
|
inline |
Remove counter from register.
| std::exception-derived | exceptions originating from standard library. |
Definition at line 346 of file register.hpp.