libsysprof-profile: add writer to recording object

This commit is contained in:
Christian Hergert
2023-05-25 16:26:18 -07:00
parent 93153d1943
commit 2ae33917b2
2 changed files with 23 additions and 4 deletions

View File

@ -24,6 +24,7 @@
G_BEGIN_DECLS
SysprofRecording *_sysprof_recording_new (void);
SysprofRecording *_sysprof_recording_new (SysprofCaptureWriter *writer);
SysprofCaptureWriter *_sysprof_recording_writer (SysprofRecording *self);
G_END_DECLS

View File

@ -36,9 +36,20 @@ struct _SysprofRecording
{
GObject parent_instance;
SysprofRecordingState state : 3;
/* This is where all of the instruments will write to. They are
* expected to do this from the main-thread only. To work from
* additional threads they need to proxy that state to the
* main thread for writing.
*/
SysprofCaptureWriter *writer;
/* Waiters contains a list of GTask to complete calls to the
* sysprof_recording_wait_async() flow.
*/
GQueue waiters;
/* Our current state of operation */
SysprofRecordingState state : 3;
};
enum {
@ -135,9 +146,16 @@ sysprof_recording_init (SysprofRecording *self)
}
SysprofRecording *
_sysprof_recording_new (void)
_sysprof_recording_new (SysprofCaptureWriter *writer)
{
return g_object_new (SYSPROF_TYPE_RECORDING, NULL);
SysprofRecording *self;
g_return_val_if_fail (writer != NULL, NULL);
self = g_object_new (SYSPROF_TYPE_RECORDING, NULL);
self->writer = sysprof_capture_writer_ref (writer);
return self;
}
void