1/**
2 * hdr_interval_recorder.h
3 * Written by Michael Barker and released to the public domain,
4 * as explained at http://creativecommons.org/publicdomain/zero/1.0/
5 */
6
7#ifndef HDR_INTERVAL_RECORDER_H
8#define HDR_INTERVAL_RECORDER_H 1
9
10#include "hdr_writer_reader_phaser.h"
11#include "hdr_histogram.h"
12
13HDR_ALIGN_PREFIX(8)
14struct hdr_interval_recorder
15{
16    void* active;
17    void* inactive;
18    struct hdr_writer_reader_phaser phaser;
19}
20HDR_ALIGN_SUFFIX(8);
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26int hdr_interval_recorder_init(struct hdr_interval_recorder* r);
27
28int hdr_interval_recorder_init_all(
29    struct hdr_interval_recorder* r,
30    int64_t lowest_trackable_value,
31    int64_t highest_trackable_value,
32    int significant_figures);
33
34void hdr_interval_recorder_destroy(struct hdr_interval_recorder* r);
35
36void hdr_interval_recorder_update(
37    struct hdr_interval_recorder* r,
38    void(*update_action)(void*, void*),
39    void* arg);
40
41int64_t hdr_interval_recorder_record_value(
42    struct hdr_interval_recorder* r,
43    int64_t value
44);
45
46int64_t hdr_interval_recorder_record_values(
47    struct hdr_interval_recorder* r,
48    int64_t value,
49    int64_t count
50);
51
52int64_t hdr_interval_recorder_record_corrected_value(
53    struct hdr_interval_recorder* r,
54    int64_t value,
55    int64_t expected_interval
56);
57
58int64_t hdr_interval_recorder_record_corrected_values(
59    struct hdr_interval_recorder* r,
60    int64_t value,
61    int64_t count,
62    int64_t expected_interval
63);
64
65void* hdr_interval_recorder_sample(struct hdr_interval_recorder* r);
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif
72