HawkTracer  0.9.0
timeline.h
Go to the documentation of this file.
1 #ifndef HAWKTRACER_TIMELINE_H
2 #define HAWKTRACER_TIMELINE_H
3 
4 #include <hawktracer/events.h>
8 
9 #include <stddef.h>
10 
14 #define HT_TIMELINE_FEATURE(timeline, feature_id, feature_type) \
15  ((feature_type*)ht_timeline_get_feature(timeline, feature_id))
16 
18 #define HT_TIMELINE_MAX_FEATURES 32
19 
21 
22 typedef struct _HT_Timeline HT_Timeline;
23 
24 HT_API HT_Timeline* ht_timeline_create(size_t buffer_capacity,
25  HT_Boolean thread_safe,
26  HT_Boolean serialize_events,
27  const char* listeners,
28  HT_ErrorCode* out_err);
29 
35 HT_API void ht_timeline_destroy(HT_Timeline* timeline);
36 
47  HT_Timeline* timeline,
49  void* user_data);
50 
57 
66 HT_API void ht_timeline_init_event(HT_Timeline* timeline, HT_Event* event);
67 
74 HT_API void ht_timeline_push_event(HT_Timeline* timeline, HT_Event* event);
75 
81 HT_API void ht_timeline_flush(HT_Timeline* timeline);
82 
83 HT_API void ht_timeline_set_feature(HT_Timeline* timeline, size_t feature_id, void* feature);
84 
85 HT_API void* ht_timeline_get_feature(HT_Timeline* timeline, size_t feature_id);
86 
88 
99 #define HT_TIMELINE_PUSH_EVENT(TIMELINE, EVENT_TYPE, ...) \
100  HT_TIMELINE_PUSH_EVENT_PEDANTIC(TIMELINE, EVENT_TYPE, ht_base_event, __VA_ARGS__)
101 
126 #define HT_TIMELINE_PUSH_EVENT_PEDANTIC(TIMELINE, EVENT_TYPE, ...) \
127  do { \
128  HT_Event ht_base_event = { \
129  ht_##EVENT_TYPE##_get_event_klass_instance(), \
130  ht_monotonic_clock_get_timestamp(), \
131  ht_event_id_provider_next(ht_timeline_get_id_provider(TIMELINE)) \
132  }; \
133  EVENT_TYPE ev = {__VA_ARGS__}; \
134  ht_timeline_push_event(TIMELINE, HT_EVENT(&ev)); \
135  } while (0)
136 
138 
139 #endif /* HAWKTRACER_TIMELINE_H */
HT_API HT_Timeline * ht_timeline_create(size_t buffer_capacity, HT_Boolean thread_safe, HT_Boolean serialize_events, const char *listeners, HT_ErrorCode *out_err)
HT_API void ht_timeline_flush(HT_Timeline *timeline)
Transfers all the events from internal buffer to listeners.
#define HT_API
Defines a directive for exporting/importing symbols from DLL.
Definition: macros.h:76
#define HT_DECLS_END
Defines an end of C linkage block.
Definition: macros.h:17
HT_API void ht_timeline_set_feature(HT_Timeline *timeline, size_t feature_id, void *feature)
HT_API HT_ErrorCode ht_timeline_register_listener(HT_Timeline *timeline, HT_TimelineListenerCallback callback, void *user_data)
Registers new listener to a timeline.
typedefHT_DECLS_BEGIN struct _HT_Timeline HT_Timeline
Definition: timeline.h:22
HT_ErrorCode
Defines list of possible errors returned by library functions.
Definition: base_types.h:37
int HT_Boolean
A standard boolean type, possible values: HT_TRUE, HT_FALSE.
Definition: base_types.h:20
HT_DECLS_BEGIN typedef void(* HT_TimelineListenerCallback)(TEventPtr events, size_t buffer_size, HT_Boolean serialized, void *user_data)
A callback for the timeline listener.
Definition: timeline_listener.h:20
HT_API void ht_timeline_push_event(HT_Timeline *timeline, HT_Event *event)
Pushes an event to a timeline.
HT_API HT_EventIdProvider * ht_timeline_get_id_provider(HT_Timeline *timeline)
HT_API void ht_timeline_destroy(HT_Timeline *timeline)
Destroys a timeline.
typedefHT_DECLS_BEGIN struct _HT_EventIdProvider HT_EventIdProvider
HT_EventIdProvider is a sequence number generator.
Definition: event_id_provider.h:13
#define HT_DECLS_BEGIN
Defines a beginning of C linkage block.
Definition: macros.h:16
HT_API void * ht_timeline_get_feature(HT_Timeline *timeline, size_t feature_id)
HT_DECLS_BEGIN HT_Event
Definition: core_events.h:11
HT_API void ht_timeline_init_event(HT_Timeline *timeline, HT_Event *event)
Initializes event according to timeline&#39;s parameters.
HT_API void ht_timeline_unregister_all_listeners(HT_Timeline *timeline)
Removes all the listeners from a timeline.