PebbleOS
Loading...
Searching...
No Matches
Data Structures | Functions
shared_cbuf.h File Reference
#include <pbl/util/list.h>
#include <pbl/kernel/compiler.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Data Structures

struct  pbl_shared_cbuf_client
 Read client, allocated by the caller. More...
 
struct  pbl_shared_cbuf
 Shared circular buffer state. More...
 
struct  pbl_shared_cbuf_subsampled_client
 Read client that keeps only a fraction of fixed-size items. More...
 

Functions

void pbl_shared_cbuf_init (struct pbl_shared_cbuf *buffer, uint8_t *storage, uint16_t storage_size)
 Initialize a shared circular buffer, without clients.
 
bool pbl_shared_cbuf_write (struct pbl_shared_cbuf *buffer, const uint8_t *data, uint16_t length, bool advance_slackers)
 Write data to the buffer.
 
bool pbl_shared_cbuf_write_reserve (struct pbl_shared_cbuf *buffer, uint16_t length, bool advance_slackers, uint8_t **seg1, uint16_t *seg1_length, uint8_t **seg2)
 Reserve write space to fill in place.
 
void pbl_shared_cbuf_write_commit (struct pbl_shared_cbuf *buffer, uint16_t length)
 Commit a reservation made with pbl_shared_cbuf_write_reserve().
 
bool pbl_shared_cbuf_add_client (struct pbl_shared_cbuf *buffer, struct pbl_shared_cbuf_client *client)
 Add a read client.
 
void pbl_shared_cbuf_remove_client (struct pbl_shared_cbuf *buffer, struct pbl_shared_cbuf_client *client)
 Remove a read client.
 
bool pbl_shared_cbuf_read (const struct pbl_shared_cbuf *buffer, struct pbl_shared_cbuf_client *client, uint16_t length, const uint8_t **data_out, uint16_t *length_out)
 Get a pointer to the oldest data of a client, without consuming it.
 
bool pbl_shared_cbuf_consume (struct pbl_shared_cbuf *buffer, struct pbl_shared_cbuf_client *client, uint16_t length)
 Remove the oldest data of a client.
 
uint16_t pbl_shared_cbuf_get_write_space_remaining (const struct pbl_shared_cbuf *buffer)
 Get the free space, limited by the client farthest behind.
 
uint16_t pbl_shared_cbuf_get_read_space_remaining (const struct pbl_shared_cbuf *buffer, struct pbl_shared_cbuf_client *client)
 Get the amount of data available to a client.
 
bool pbl_shared_cbuf_read_consume (struct pbl_shared_cbuf *buffer, struct pbl_shared_cbuf_client *client, uint16_t length, uint8_t *data, uint16_t *length_out)
 Copy out and consume data of a client, handling the wrap.
 
void pbl_shared_cbuf_add_subsampled_client (struct pbl_shared_cbuf *buffer, struct pbl_shared_cbuf_subsampled_client *client, uint32_t subsample_numerator, uint32_t subsample_denominator)
 Add a read client that subsamples the data.
 
void pbl_shared_cbuf_remove_subsampled_client (struct pbl_shared_cbuf *buffer, struct pbl_shared_cbuf_subsampled_client *client)
 Remove a subsampling read client.
 
void pbl_shared_cbuf_subsampled_client_set_ratio (struct pbl_shared_cbuf_subsampled_client *client, uint32_t numerator, uint32_t denominator)
 Change the subsampling ratio of a client.
 
size_t pbl_shared_cbuf_read_subsampled (struct pbl_shared_cbuf *buffer, struct pbl_shared_cbuf_subsampled_client *client, size_t item_size, void *data, uint16_t num_items)
 Read and consume items with subsampling.