[sysprof] writer: allow callers to define a counter range
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] writer: allow callers to define a counter range
- Date: Fri, 15 Apr 2016 04:36:55 +0000 (UTC)
commit d7ed2ddf301908ebf7c87f609da3b0a29f853c7e
Author: Christian Hergert <christian hergert me>
Date: Thu Apr 14 21:36:07 2016 -0700
writer: allow callers to define a counter range
This allows dynamic counter ids that can be allocated in blocks.
lib/sp-capture-writer.c | 18 ++++++++++++++++++
lib/sp-capture-writer.h | 2 ++
2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/lib/sp-capture-writer.c b/lib/sp-capture-writer.c
index b416c57..55c4503 100644
--- a/lib/sp-capture-writer.c
+++ b/lib/sp-capture-writer.c
@@ -90,6 +90,9 @@ struct _SpCaptureWriter
gsize pos;
gsize len;
+ /* counter id sequence */
+ gint next_counter_id;
+
/* Statistics while recording */
SpCaptureStat stat;
};
@@ -378,6 +381,7 @@ sp_capture_writer_new_from_fd (int fd,
self->fd = fd;
self->buf = (guint8 *)g_malloc (buffer_size);
self->len = buffer_size;
+ self->next_counter_id = 1;
g_get_current_time (&tv);
nowstr = g_time_val_to_iso8601 (&tv);
@@ -1086,3 +1090,17 @@ sp_capture_writer_set_counters (SpCaptureWriter *self,
return TRUE;
}
+
+gint
+sp_capture_writer_request_counter (SpCaptureWriter *self,
+ guint n_counters)
+{
+ gint ret;
+
+ g_assert (self != NULL);
+
+ ret = self->next_counter_id;
+ ret += n_counters;
+
+ return ret;
+}
diff --git a/lib/sp-capture-writer.h b/lib/sp-capture-writer.h
index 81de7de..bdc35bf 100644
--- a/lib/sp-capture-writer.h
+++ b/lib/sp-capture-writer.h
@@ -98,6 +98,8 @@ gboolean sp_capture_writer_flush (SpCaptureWriter *
gboolean sp_capture_writer_save_as (SpCaptureWriter *self,
const gchar *filename,
GError **error);
+gint sp_capture_writer_request_counter (SpCaptureWriter *self,
+ guint n_counters);
SpCaptureReader *sp_capture_writer_create_reader (SpCaptureWriter *self,
GError **error);
gboolean sp_capture_writer_splice (SpCaptureWriter *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]