mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
writer: allow callers to define a counter range
This allows dynamic counter ids that can be allocated in blocks.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user