iterator: move auto-seek data in its own struct, add comments
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 17 Jun 2019 16:56:24 +0000 (12:56 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 27 Jun 2019 17:58:21 +0000 (13:58 -0400)
Further patches will add more fields related to this feature, so it
seems useful to group them under the same (anonymous) struct.

No functional changes intended.

Change-Id: I6ed922801cf5bd9001d388d7d8b050a6c8d01790
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1484
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/lib/graph/iterator.c
src/lib/graph/message/iterator.h

index b6117e125c05b36110ca7db4921fffefd1d64e6c..6fd22af01d5695219493c218a85e4760ee4838ab 100644 (file)
@@ -144,14 +144,14 @@ void bt_self_component_port_input_message_iterator_destroy(struct bt_object *obj
                iterator->connection = NULL;
        }
 
-       if (iterator->auto_seek_msgs) {
-               while (!g_queue_is_empty(iterator->auto_seek_msgs)) {
+       if (iterator->auto_seek.msgs) {
+               while (!g_queue_is_empty(iterator->auto_seek.msgs)) {
                        bt_object_put_no_null_check(
-                               g_queue_pop_tail(iterator->auto_seek_msgs));
+                               g_queue_pop_tail(iterator->auto_seek.msgs));
                }
 
-               g_queue_free(iterator->auto_seek_msgs);
-               iterator->auto_seek_msgs = NULL;
+               g_queue_free(iterator->auto_seek.msgs);
+               iterator->auto_seek.msgs = NULL;
        }
 
        destroy_base_message_iterator(obj);
@@ -316,8 +316,8 @@ bt_self_component_port_input_message_iterator_create_initial(
                goto end;
        }
 
-       iterator->auto_seek_msgs = g_queue_new();
-       if (!iterator->auto_seek_msgs) {
+       iterator->auto_seek.msgs = g_queue_new();
+       if (!iterator->auto_seek.msgs) {
                BT_LOGE_STR("Failed to allocate a GQueue.");
                ret = -1;
                goto end;
@@ -1141,7 +1141,7 @@ skip_msg:
        goto end;
 
 push_msg:
-       g_queue_push_tail(iterator->auto_seek_msgs, (void *) msg);
+       g_queue_push_tail(iterator->auto_seek.msgs, (void *) msg);
        msg = NULL;
 
 end:
@@ -1210,7 +1210,7 @@ enum bt_message_iterator_status find_message_ge_ns_from_origin(
 
                for (i = 0; i < user_count; i++) {
                        if (got_first) {
-                               g_queue_push_tail(iterator->auto_seek_msgs,
+                               g_queue_push_tail(iterator->auto_seek.msgs,
                                        (void *) messages[i]);
                                messages[i] = NULL;
                                continue;
@@ -1244,22 +1244,22 @@ enum bt_self_message_iterator_status post_auto_seek_next(
                bt_message_array_const msgs, uint64_t capacity,
                uint64_t *count)
 {
-       BT_ASSERT(!g_queue_is_empty(iterator->auto_seek_msgs));
+       BT_ASSERT(!g_queue_is_empty(iterator->auto_seek.msgs));
        *count = 0;
 
        /*
         * Move auto-seek messages to the output array (which is this
         * iterator's base message array).
         */
-       while (capacity > 0 && !g_queue_is_empty(iterator->auto_seek_msgs)) {
-               msgs[*count] = g_queue_pop_head(iterator->auto_seek_msgs);
+       while (capacity > 0 && !g_queue_is_empty(iterator->auto_seek.msgs)) {
+               msgs[*count] = g_queue_pop_head(iterator->auto_seek.msgs);
                capacity--;
                (*count)++;
        }
 
        BT_ASSERT(*count > 0);
 
-       if (g_queue_is_empty(iterator->auto_seek_msgs)) {
+       if (g_queue_is_empty(iterator->auto_seek.msgs)) {
                /* No more auto-seek messages */
                switch (iterator->upstream_component->class->type) {
                case BT_COMPONENT_CLASS_TYPE_SOURCE:
@@ -1360,9 +1360,9 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin(
                 * this point in the batch to this iterator's auto-seek
                 * message queue.
                 */
-               while (!g_queue_is_empty(iterator->auto_seek_msgs)) {
+               while (!g_queue_is_empty(iterator->auto_seek.msgs)) {
                        bt_object_put_no_null_check(
-                               g_queue_pop_tail(iterator->auto_seek_msgs));
+                               g_queue_pop_tail(iterator->auto_seek.msgs));
                }
 
                status = find_message_ge_ns_from_origin(iterator,
@@ -1376,7 +1376,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin(
                         * method with a custom, temporary "next" method
                         * which returns them.
                         */
-                       if (!g_queue_is_empty(iterator->auto_seek_msgs)) {
+                       if (!g_queue_is_empty(iterator->auto_seek.msgs)) {
                                iterator->methods.next =
                                        (bt_self_component_port_input_message_iterator_next_method)
                                                post_auto_seek_next;
index 2c442a15db749f2ca4ff5610684806cf8b7d0b93..1ecaa95a991d29329a2816d1ffcc6dd0ca160bca 100644 (file)
@@ -112,7 +112,27 @@ struct bt_self_component_port_input_message_iterator {
        } methods;
 
        enum bt_self_component_port_input_message_iterator_state state;
-       GQueue *auto_seek_msgs;
+
+       /*
+        * 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;
+       } auto_seek;
+
        void *user_data;
 };
 
This page took 0.02918 seconds and 4 git commands to generate.