#ifndef AWS_COMMON_STATISTICS_H
#define AWS_COMMON_STATISTICS_H
#include <aws/common/common.h>
#include <aws/common/package.h>
#include <aws/common/stdint.h>
struct aws_array_list;
typedef uint32_t aws_crt_statistics_category_t;
#define AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS 8
#define AWS_CRT_STATISTICS_CATEGORY_STRIDE (1U << AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS)
#define AWS_CRT_STATISTICS_CATEGORY_BEGIN_RANGE(x) ((x)*AWS_CRT_STATISTICS_CATEGORY_STRIDE)
#define AWS_CRT_STATISTICS_CATEGORY_END_RANGE(x) (((x) + 1) * AWS_CRT_STATISTICS_CATEGORY_STRIDE - 1)
enum aws_crt_common_statistics_category {
AWSCRT_STAT_CAT_INVALID = AWS_CRT_STATISTICS_CATEGORY_BEGIN_RANGE(AWS_C_COMMON_PACKAGE_ID)
};
struct aws_crt_statistics_base {
aws_crt_statistics_category_t category;
};
struct aws_crt_statistics_sample_interval {
uint64_t begin_time_ms;
uint64_t end_time_ms;
};
struct aws_crt_statistics_handler;
typedef void(aws_crt_statistics_handler_process_statistics_fn)(
struct aws_crt_statistics_handler *handler,
struct aws_crt_statistics_sample_interval *interval,
struct aws_array_list *stats,
void *context);
typedef void(aws_crt_statistics_handler_destroy_fn)(struct aws_crt_statistics_handler *handler);
typedef uint64_t(aws_crt_statistics_handler_get_report_interval_ms_fn)(struct aws_crt_statistics_handler *);
struct aws_crt_statistics_handler_vtable {
aws_crt_statistics_handler_process_statistics_fn *process_statistics;
aws_crt_statistics_handler_destroy_fn *destroy;
aws_crt_statistics_handler_get_report_interval_ms_fn *get_report_interval_ms;
};
struct aws_crt_statistics_handler {
struct aws_crt_statistics_handler_vtable *vtable;
struct aws_allocator *allocator;
void *impl;
};
AWS_EXTERN_C_BEGIN
AWS_COMMON_API
void aws_crt_statistics_handler_process_statistics(
struct aws_crt_statistics_handler *handler,
struct aws_crt_statistics_sample_interval *interval,
struct aws_array_list *stats,
void *context);
AWS_COMMON_API
uint64_t aws_crt_statistics_handler_get_report_interval_ms(struct aws_crt_statistics_handler *handler);
AWS_COMMON_API
void aws_crt_statistics_handler_destroy(struct aws_crt_statistics_handler *handler);
AWS_EXTERN_C_END
#endif