[sysprof] libsysprof-capture: add clear/reset API for mapped ring buffer
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-capture: add clear/reset API for mapped ring buffer
- Date: Mon, 17 Feb 2020 00:57:31 +0000 (UTC)
commit 53a351b66eab09fd9cff272300b34d9dc286d6ed
Author: Christian Hergert <chergert redhat com>
Date: Sun Feb 16 10:17:12 2020 -0700
libsysprof-capture: add clear/reset API for mapped ring buffer
src/libsysprof-capture/mapped-ring-buffer.c | 22 ++++++++++++++++++++++
src/libsysprof-capture/mapped-ring-buffer.h | 2 ++
2 files changed, 24 insertions(+)
---
diff --git a/src/libsysprof-capture/mapped-ring-buffer.c b/src/libsysprof-capture/mapped-ring-buffer.c
index b051a54..11499b6 100644
--- a/src/libsysprof-capture/mapped-ring-buffer.c
+++ b/src/libsysprof-capture/mapped-ring-buffer.c
@@ -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;
+}
diff --git a/src/libsysprof-capture/mapped-ring-buffer.h b/src/libsysprof-capture/mapped-ring-buffer.h
index 45387c3..4eee695 100644
--- a/src/libsysprof-capture/mapped-ring-buffer.h
+++ b/src/libsysprof-capture/mapped-ring-buffer.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]