3 * A lightweight log storage medium with limited history
6 * Alexander Kyte (alkyte@microsoft.com)
8 * (C) 2018 Microsoft, Inc.
11 #ifndef __MONO_FLIGHT_RECORDER__
12 #define __MONO_FLIGHT_RECORDER__
15 #include <mono/utils/mono-coop-mutex.h>
18 long counter
; // The number of messages allocated thus far, acts like a global, monotonic clock
19 } MonoFlightRecorderHeader
;
22 MonoFlightRecorderHeader header
;
23 gpointer payload
[MONO_ZERO_LEN_ARRAY
]; // We have a variably-sized payload
24 } MonoFlightRecorderItem
;
27 intptr_t cursor
; // Signed, for sentinel value of -1
28 size_t max_count
; // Maximum number of items in logger
29 size_t payload_size
; // Size of data reserved for logging message
30 MonoCoopMutex mutex
; // Not owned exclusively by us, used by api consumers too
31 MonoFlightRecorderItem
*items
[MONO_ZERO_LEN_ARRAY
]; // The data of the history
35 mono_flight_recorder_mutex (MonoFlightRecorder
*recorder
);
38 mono_flight_recorder_init (size_t max_size
, size_t payload_size
);
41 mono_flight_recorder_free (MonoFlightRecorder
*recorder
);
44 mono_flight_recorder_append (MonoFlightRecorder
*recorder
, gpointer payload
);
46 // Used to traverse the ring buffer in order of oldest to newest message
49 intptr_t lowest_index
;
50 intptr_t highest_index
;
51 MonoFlightRecorder
*recorder
;
52 } MonoFlightRecorderIter
;
54 // Mutex has to be held when called
56 mono_flight_recorder_iter_init (MonoFlightRecorder
*recorder
, MonoFlightRecorderIter
*iter
);
58 // Mutex has to be held when called
60 mono_flight_recorder_iter_destroy (MonoFlightRecorderIter
*iter
);
62 // Mutex has to be held when called
64 mono_flight_recorder_iter_next (MonoFlightRecorderIter
*iter
, MonoFlightRecorderHeader
*header
, gpointer
*payload
);