X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fgraph%2Fmessage%2Fiterator.h;h=d28a88102ac0be6dc53cdb44aae8c8dc88baa7d6;hb=d24d56638469189904fb6ddbb3c725817b3e9417;hp=475abf555cc40d7a8e391976dc6173f64d4c503e;hpb=91d8147391efdc4d42cc4e1c171a65c0372a008f;p=babeltrace.git diff --git a/src/lib/graph/message/iterator.h b/src/lib/graph/message/iterator.h index 475abf55..d28a8810 100644 --- a/src/lib/graph/message/iterator.h +++ b/src/lib/graph/message/iterator.h @@ -28,10 +28,10 @@ #include "lib/object.h" #include #include -#include #include #include "common/assert.h" #include +#include struct bt_port; struct bt_graph; @@ -76,15 +76,15 @@ struct bt_message_iterator { GPtrArray *msgs; }; -typedef enum bt_self_message_iterator_status +typedef enum bt_component_class_message_iterator_next_method_status (*bt_self_component_port_input_message_iterator_next_method)( void *, bt_message_array_const, uint64_t, uint64_t *); -typedef enum bt_self_message_iterator_status +typedef enum bt_component_class_message_iterator_seek_ns_from_origin_method_status (*bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)( void *, int64_t); -typedef enum bt_self_message_iterator_status +typedef enum bt_component_class_message_iterator_seek_beginning_method_status (*bt_self_component_port_input_message_iterator_seek_beginning_method)( void *); @@ -112,7 +112,69 @@ struct bt_self_component_port_input_message_iterator { } methods; enum bt_self_component_port_input_message_iterator_state state; - GQueue *auto_seek_msgs; + + /* + * Timestamp of the last received message (or INT64_MIN in the + * beginning, or after a seek to beginning). + */ + int64_t last_ns_from_origin; + + struct { + enum { + /* We haven't recorded clock properties yet. */ + CLOCK_EXPECTATION_UNSET, + + /* Expect to have no clock. */ + CLOCK_EXPECTATION_NONE, + + /* Clock with origin_is_unix_epoch true.*/ + CLOCK_EXPECTATION_ORIGIN_UNIX, + + /* Clock with origin_is_unix_epoch false, with a UUID.*/ + CLOCK_EXPECTATION_ORIGIN_OTHER_UUID, + + /* Clock with origin_is_unix_epoch false, without a UUID.*/ + CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID, + } type; + + /* + * Expected UUID of the clock, if `type`is CLOCK_EXPECTATION_ORIGIN_OTHER_UUID. + * + * If the clock's origin is the unix epoch, the UUID is + * irrelevant (as the clock will be correlatable with other + * clocks having the same origin). + */ + uint8_t uuid[BABELTRACE_UUID_LEN]; + } clock_expectation; + + /* + * Data necessary for auto seek (the seek-to-beginning then fast-forward + * seek strategy). + */ + struct { + /* + * Queue of `const bt_message *` (owned by this queue). + * + * When fast-forwarding, we get the messages from upstream in + * batches. Once we have found the first message with timestamp + * greater or equal to the seek time, we put it and all of the + * following message of the batch in this queue. They will be + * sent on the next "next" call on this iterator. + * + * The messages are in chronological order (i.e. the first to + * send is the first of the queue). + */ + GQueue *msgs; + + /* + * After auto-seeking, we replace the iterator's `next` callback + * with our own, which returns the contents of the `msgs` queue. + * This field is where we save the original callback, so we can + * restore it. + */ + void *original_next_callback; + } auto_seek; + void *user_data; }; @@ -137,26 +199,6 @@ void bt_self_component_port_input_message_iterator_set_connection( struct bt_self_component_port_input_message_iterator *iterator, struct bt_connection *connection); -static inline -const char *bt_message_iterator_status_string( - enum bt_message_iterator_status status) -{ - switch (status) { - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - return "BT_MESSAGE_ITERATOR_STATUS_AGAIN"; - case BT_MESSAGE_ITERATOR_STATUS_END: - return "BT_MESSAGE_ITERATOR_STATUS_END"; - case BT_MESSAGE_ITERATOR_STATUS_OK: - return "BT_MESSAGE_ITERATOR_STATUS_OK"; - case BT_MESSAGE_ITERATOR_STATUS_ERROR: - return "BT_MESSAGE_ITERATOR_STATUS_ERROR"; - case BT_MESSAGE_ITERATOR_STATUS_NOMEM: - return "BT_MESSAGE_ITERATOR_STATUS_NOMEM"; - default: - return "(unknown)"; - } -}; - static inline const char *bt_self_component_port_input_message_iterator_state_string( enum bt_self_component_port_input_message_iterator_state state)