|
Marine Library
1.0
C++ library for Linux Networking Development
|
Program statistics and profiling. More...
#include "impl/attr_stats_impl.hh"Go to the source code of this file.
Macros | |
| #define | ATTR_ADD(attr, val) |
| Increase an attribute atomically. More... | |
| #define | ATTR_SET(attr, val) |
| Modify an attribute atomically. More... | |
| #define | ATTR_SET_EX(attr, val, old) |
| Get an attribute and then modify it atomically. More... | |
Functions | |
| bool | ATTR_INIT (size_t capacity=1000) |
| Initialize statistics APIs. More... | |
| bool | ATTR_ADD_SLOW (int attr, uint64_t val) |
| Increase an attribute atomically. More... | |
| bool | ATTR_SET_SLOW (int attr, uint64_t val, uint64_t *old=NULL) |
| Get an attribute and then modify it atomically. More... | |
| template<class Op > | |
| void | ATTR_ITERATE (Op op) |
| Iterate and apply an operation to all attributes. More... | |
Program statistics and profiling.
APIs for profiling program based on lock-free, thread-safe counters.
Each counter is called an attribute, identified by an positive integer. You can put as many attributes in program as you want.
| #define ATTR_ADD | ( | attr, | |
| val | |||
| ) |
Increase an attribute atomically.
An example usage shows below:
| attr | A positive number identifying the attribute |
| val | A non-negative number to add to the attribute |
attr must be a constant expression, i.e. can be evaluated at compile time. And this is the recommended way of usage. | #define ATTR_SET | ( | attr, | |
| val | |||
| ) |
Modify an attribute atomically.
An example usage shows below:
| attr | A positive number identifying the attribute |
| val | A non-negative number |
attr must be a constant expression, i.e. can be evaluated at compile time. And this is the recommended way of usage. | #define ATTR_SET_EX | ( | attr, | |
| val, | |||
| old | |||
| ) |
Get an attribute and then modify it atomically.
| [in] | attr | A positive number identifying the attribute |
| [in] | val | A non-negative number |
| [out] | old | Pointer to a variable to receive the value of attribute before modification; or NULL if not interested |
attr must be a constant expression, i.e. can be evaluated at compile time. And this is the recommended way of usage.
|
inline |
Increase an attribute atomically.
| attr | A positive number identifying the attribute |
| val | A non-negative number to add to the attribute |
true if succeeded; otherwise false
|
inline |
Initialize statistics APIs.
This function must be called once only before any other statistics APIs.
| capacity | The maximum number of attributes in the program |
true if succeeded; otherwise false
|
inline |
Iterate and apply an operation to all attributes.
| op | Operation to apply to all attributes, should implement: void operator ()(int attr, uint64_t value) const;
|
|
inline |
Get an attribute and then modify it atomically.
| [in] | attr | A positive number identifying the attribute |
| [in] | val | A non-negative number |
| [out] | old | Pointer to a variable to receive the value of attribute before modification; or NULL if not interested |
1.8.11