libosmocore 1.9.0.196-9975
Osmocom core library
osmo_time_cc Struct Reference

Report the cumulative counter of time for which a flag is true as rate counter. More...

#include <time_cc.h>

Data Fields

struct osmo_time_cc_cfg cfg
 
bool flag_state
 
uint64_t total_sum
 Overall cumulative sum. More...
 
struct osmo_timer_list timer
 
uint64_t start_time
 CLOCK_MONOTONIC reading in microseconds, at the time when the osmo_time_cc instance started counting. More...
 
uint64_t last_counted_time
 CLOCK_MONOTONIC reading in microseconds, at the time when the osmo_time_cc last evaluated the flag state and possibly added to the cumulated sum. More...
 
uint64_t sum
 Internal cumulative counter of time that flag_state was true. More...
 
uint64_t reported_sum
 The amount of time that already reported cfg.rate_ctr increments account for. More...
 

Detailed Description

Report the cumulative counter of time for which a flag is true as rate counter.

See also osmo_time_cc_cfg for details on configuring.

Usage:

struct my_obj {
        struct osmo_time_cc flag_cc;
};

void my_obj_init(struct my_obj *my_obj)
{
        osmo_time_cc_init(&my_obj->flag_cc);
        my_obj->flag_cc.cfg = (struct osmo_time_cc_cfg){
                        .gran_usec = 1000000,
                        .forget_sum_usec = 60000000,
                        .rate_ctr = rate_ctr_group_get_ctr(my_ctrg, MY_CTR_IDX),
                };
        // optional: set initial flag state, default is 'false':
        // osmo_time_cc_set_flag(&my_obj->flag_cc, false);
}

void my_obj_event(struct my_obj *my_obj, bool flag)
{
        osmo_time_cc_set_flag(&my_obj->flag_cc, flag);
}

void my_obj_destruct(struct my_obj *my_obj)
{
        osmo_time_cc_cleanup(&my_obj->flag_cc);
}

Field Documentation

◆ cfg

struct osmo_time_cc_cfg osmo_time_cc::cfg

◆ flag_state

bool osmo_time_cc::flag_state

◆ last_counted_time

uint64_t osmo_time_cc::last_counted_time

CLOCK_MONOTONIC reading in microseconds, at the time when the osmo_time_cc last evaluated the flag state and possibly added to the cumulated sum.

◆ reported_sum

uint64_t osmo_time_cc::reported_sum

The amount of time that already reported cfg.rate_ctr increments account for.

This may be ahead of or behind 'sum', depending on cfg.round_threshold_usec.

◆ start_time

uint64_t osmo_time_cc::start_time

CLOCK_MONOTONIC reading in microseconds, at the time when the osmo_time_cc instance started counting.

◆ sum

uint64_t osmo_time_cc::sum

Internal cumulative counter of time that flag_state was true.

It may get reset to zero regularly, depending on cfg.forget_sum_usec. This is the basis for incrementing cfg.rate_ctr.

◆ timer

struct osmo_timer_list osmo_time_cc::timer

◆ total_sum

uint64_t osmo_time_cc::total_sum

Overall cumulative sum.

Does not get reset for the entire lifetime of an osmo_time_cc. (Informational only, not used by the osmo_time_cc implementation.)


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