lib: use object pool for event and packet notifications
[babeltrace.git] / plugins / ctf / common / notif-iter / notif-iter.c
index 7128e184ba3821272e1d689415b9c0c795a06843..4f295a4d31acc6665c6ddd060eb0733ed11f3d2e 100644 (file)
@@ -132,6 +132,9 @@ struct bt_notif_iter {
        /* Visit stack */
        struct stack *stack;
 
+       /* Current graph to create notifications (weak) */
+       struct bt_graph *graph;
+
        /*
         * Current dynamic scope field pointer.
         *
@@ -1582,8 +1585,10 @@ enum bt_notif_iter_status set_current_event_notification(
                notit, notit->meta.event_class,
                bt_event_class_get_name(notit->meta.event_class),
                notit->packet);
-       notif = bt_notification_event_create(notit->meta.event_class,
-               notit->packet, notit->meta.cc_prio_map);
+       BT_ASSERT(notit->graph);
+       notif = bt_notification_event_create(notit->graph,
+               notit->meta.event_class, notit->packet,
+               notit->meta.cc_prio_map);
        if (!notif) {
                BT_LOGE("Cannot create event notification: "
                        "notit-addr=%p, ec-addr=%p, ec-name=\"%s\", "
@@ -2759,7 +2764,8 @@ void notify_new_stream(struct bt_notif_iter *notit,
        }
 
        BT_ASSERT(notit->stream);
-       ret = bt_notification_stream_begin_create(notit->stream);
+       BT_ASSERT(notit->graph);
+       ret = bt_notification_stream_begin_create(notit->graph, notit->stream);
        if (!ret) {
                BT_LOGE("Cannot create stream beginning notification: "
                        "notit-addr=%p, stream-addr=%p",
@@ -2783,7 +2789,8 @@ void notify_end_of_stream(struct bt_notif_iter *notit,
                return;
        }
 
-       ret = bt_notification_stream_end_create(notit->stream);
+       BT_ASSERT(notit->graph);
+       ret = bt_notification_stream_end_create(notit->graph, notit->stream);
        if (!ret) {
                BT_LOGE("Cannot create stream beginning notification: "
                        "notit-addr=%p, stream-addr=%p",
@@ -2844,7 +2851,9 @@ void notify_new_packet(struct bt_notif_iter *notit,
                        notit->dscopes.stream_packet_context);
        }
 
-       notif = bt_notification_packet_begin_create(notit->packet);
+       BT_ASSERT(notit->graph);
+       notif = bt_notification_packet_begin_create(notit->graph,
+               notit->packet);
        if (!notif) {
                BT_LOGE("Cannot create packet beginning notification: "
                        "notit-addr=%p, packet-addr=%p",
@@ -2866,7 +2875,8 @@ void notify_end_of_packet(struct bt_notif_iter *notit,
                return;
        }
 
-       notif = bt_notification_packet_end_create(notit->packet);
+       BT_ASSERT(notit->graph);
+       notif = bt_notification_packet_end_create(notit->graph, notit->packet);
        if (!notif) {
                BT_LOGE("Cannot create packet end notification: "
                        "notit-addr=%p, packet-addr=%p",
@@ -3051,6 +3061,7 @@ void bt_notif_iter_destroy(struct bt_notif_iter *notit)
 enum bt_notif_iter_status bt_notif_iter_get_next_notification(
                struct bt_notif_iter *notit,
                struct bt_clock_class_priority_map *cc_prio_map,
+               struct bt_graph *graph,
                struct bt_notification **notification)
 {
        int ret;
@@ -3059,15 +3070,17 @@ enum bt_notif_iter_status bt_notif_iter_get_next_notification(
        BT_ASSERT(notit);
        BT_ASSERT(notification);
 
+       if (notit->state == STATE_DONE) {
+               status = BT_NOTIF_ITER_STATUS_EOF;
+               goto end;
+       }
+
        if (cc_prio_map != notit->meta.cc_prio_map) {
                bt_put(notit->meta.cc_prio_map);
                notit->meta.cc_prio_map = bt_get(cc_prio_map);
        }
 
-       if (notit->state == STATE_DONE) {
-               status = BT_NOTIF_ITER_STATUS_EOF;
-               goto end;
-       }
+       notit->graph = graph;
 
        BT_LOGV("Getting next notification: notit-addr=%p, cc-prio-map-addr=%p",
                notit, cc_prio_map);
This page took 0.025502 seconds and 4 git commands to generate.