My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Classes | Functions
stats.c File Reference

Functions for the sending and receiving of statsitics between ctrl and runtime. More...

#include "stats.h"
#include "logging.h"
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  stat_msg_hdr
 Header for a serialized stats message. More...
 

Functions

int is_thread_stat (enum stat_id id)
 
int is_msu_stat (enum stat_id id)
 
static int init_stat_sample (int max_stats, struct stat_sample *sample)
 Initializes a single stat sample with room to hold max_stats statistics. More...
 
void free_stat_samples (struct stat_sample *sample, int n_samples)
 Frees a set of stat samples. More...
 
struct stat_sampleinit_stat_samples (int max_stats, int n_samples)
 Initilizes n sets of samples of statistics, each of which contains max_stats points. More...
 
size_t serialized_stat_sample_size (struct stat_sample *sample, int n_samples)
 Determines the size needed to hold the serialized version of sample. More...
 
static ssize_t serialize_stat_sample (struct stat_sample *sample, void *buffer, size_t buff_len)
 Serializes a single stat sample into a buffer of size buff_len. More...
 
ssize_t serialize_stat_samples (struct stat_sample *samples, int n_samples, void *buffer, size_t buff_len)
 Serializes from the provided samples into the buffer More...
 
static ssize_t deserialize_stat_sample (void *buffer, size_t buff_len, struct stat_sample *sample)
 Deserializes a single stat sample from a buffer. More...
 
int deserialize_stat_samples (void *buffer, size_t buff_len, struct stat_sample *samples, int n_samples)
 Deserializes from the provided buffer into the samples structure. More...
 

Detailed Description

Functions for the sending and receiving of statsitics between ctrl and runtime.

Definition in file stats.c.

Function Documentation

static ssize_t deserialize_stat_sample ( void *  buffer,
size_t  buff_len,
struct stat_sample sample 
)
static

Deserializes a single stat sample from a buffer.

Returns
0 on success, -1 on error

Definition at line 153 of file stats.c.

int deserialize_stat_samples ( void *  buffer,
size_t  buff_len,
struct stat_sample samples,
int  n_samples 
)

Deserializes from the provided buffer into the samples structure.

Parameters
bufferThe buffer to deserialize
buff_lenThe size of the serialized buffer
samplesThe structure into which to deserialize
n_samplesThe number of items allocated in samples
Returns
0 on success, -1 on error

Definition at line 176 of file stats.c.

void free_stat_samples ( struct stat_sample sample,
int  n_samples 
)

Frees a set of stat samples.

Definition at line 71 of file stats.c.

static int init_stat_sample ( int  max_stats,
struct stat_sample sample 
)
static

Initializes a single stat sample with room to hold max_stats statistics.

Definition at line 61 of file stats.c.

struct stat_sample* init_stat_samples ( int  max_stats,
int  n_samples 
)

Initilizes n sets of samples of statistics, each of which contains max_stats points.

Returns
allocated structure on success, NULL on error

Definition at line 80 of file stats.c.

int is_msu_stat ( enum stat_id  id)

Definition at line 49 of file stats.c.

int is_thread_stat ( enum stat_id  id)

Definition at line 40 of file stats.c.

static ssize_t serialize_stat_sample ( struct stat_sample sample,
void *  buffer,
size_t  buff_len 
)
static

Serializes a single stat sample into a buffer of size buff_len.

Returns
0 on success, -1 if buffer is not large enough to hold sample

Definition at line 107 of file stats.c.

ssize_t serialize_stat_samples ( struct stat_sample samples,
int  n_samples,
void *  buffer,
size_t  buff_len 
)

Serializes from the provided samples into the buffer

Parameters
samplesThe samples to deserialize
n_samplessize of samples
bufferThe buffer into which to serialize
buff_lenThe size of the allocated buffer
Returns
0 on success, -1 on error (if buffer is too small)

Definition at line 122 of file stats.c.

size_t serialized_stat_sample_size ( struct stat_sample sample,
int  n_samples 
)

Determines the size needed to hold the serialized version of sample.

Parameters
sampleThe sample to serialize
n_samplesThe number of elements in sample
Returns
size needed

Definition at line 96 of file stats.c.