libsysprof-capture: add clear/reset API for mapped ring buffer

This commit is contained in:
Christian Hergert
2020-02-16 10:17:12 -07:00
parent 2329a6e25e
commit 53a351b66e
2 changed files with 24 additions and 0 deletions

View File

@ -621,3 +621,25 @@ mapped_ring_buffer_create_source (MappedRingBuffer *self,
{
return mapped_ring_buffer_create_source_full (self, source_func, user_data, NULL);
}
/**
* mapped_ring_buffer_clear:
* @self: a #MappedRingBuffer
*
* Resets the head and tail positions back to 0.
*
* This function is only safe to call when you control both the reader
* and writer sides with mapped_ring_buffer_new_readwrite(), or are in
* control of when each side reads or writes.
*/
void
mapped_ring_buffer_clear (MappedRingBuffer *self)
{
MappedRingHeader *header;
g_return_if_fail (self != NULL);
header = get_header (self);
header->head = 0;
header->tail = 0;
}

View File

@ -66,6 +66,8 @@ MappedRingBuffer *mapped_ring_buffer_ref (MappedRingBuffer
G_GNUC_INTERNAL
void mapped_ring_buffer_unref (MappedRingBuffer *self);
G_GNUC_INTERNAL
void mapped_ring_buffer_clear (MappedRingBuffer *self);
G_GNUC_INTERNAL
gpointer mapped_ring_buffer_allocate (MappedRingBuffer *self,
gsize length);
G_GNUC_INTERNAL