lib: notification iterator: transfer a batch of notifications
[babeltrace.git] / plugins / utils / dummy / dummy.c
index 5e6987934c614cc0f600ef3a43fd747d39206aba..926a6dd56728ef9fc54449c4f448568402ed6097 100644 (file)
  * SOFTWARE.
  */
 
-#include <babeltrace/plugin/plugin-dev.h>
-#include <babeltrace/graph/connection.h>
-#include <babeltrace/graph/component.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/private-component-sink.h>
-#include <babeltrace/graph/private-port.h>
-#include <babeltrace/graph/port.h>
-#include <babeltrace/graph/private-connection.h>
-#include <babeltrace/graph/component-sink.h>
-#include <babeltrace/graph/notification-iterator.h>
-#include <babeltrace/graph/notification.h>
+#include <babeltrace/babeltrace.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <plugins-common.h>
-#include <assert.h>
+#include <babeltrace/assert-internal.h>
 #include "dummy.h"
 
 void destroy_private_dummy_data(struct dummy *dummy)
@@ -46,9 +36,9 @@ void dummy_finalize(struct bt_private_component *component)
 {
        struct dummy *dummy;
 
-       assert(component);
+       BT_ASSERT(component);
        dummy = bt_private_component_get_user_data(component);
-       assert(dummy);
+       BT_ASSERT(dummy);
        destroy_private_dummy_data(dummy);
 }
 
@@ -94,11 +84,11 @@ void dummy_port_connected(
        enum bt_connection_status conn_status;
 
        dummy = bt_private_component_get_user_data(component);
-       assert(dummy);
+       BT_ASSERT(dummy);
        connection = bt_private_port_get_private_connection(self_port);
-       assert(connection);
+       BT_ASSERT(connection);
        conn_status = bt_private_connection_create_notification_iterator(
-               connection, NULL, &iterator);
+               connection, &iterator);
        if (conn_status != BT_CONNECTION_STATUS_OK) {
                dummy->error = true;
                goto end;
@@ -113,12 +103,14 @@ end:
 enum bt_component_status dummy_consume(struct bt_private_component *component)
 {
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-       struct bt_notification *notif = NULL;
+       bt_notification_array notifs;
+       uint64_t count;
        struct dummy *dummy;
        enum bt_notification_iterator_status it_ret;
+       uint64_t i;
 
        dummy = bt_private_component_get_user_data(component);
-       assert(dummy);
+       BT_ASSERT(dummy);
 
        if (unlikely(dummy->error)) {
                ret = BT_COMPONENT_STATUS_ERROR;
@@ -131,22 +123,30 @@ enum bt_component_status dummy_consume(struct bt_private_component *component)
        }
 
        /* Consume one notification  */
-       it_ret = bt_notification_iterator_next(dummy->notif_iter);
+       it_ret = bt_private_connection_notification_iterator_next(
+               dummy->notif_iter, &notifs, &count);
        switch (it_ret) {
-       case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
-               ret = BT_COMPONENT_STATUS_ERROR;
-               goto end;
+       case BT_NOTIFICATION_ITERATOR_STATUS_OK:
+               ret = BT_COMPONENT_STATUS_OK;
+
+               for (i = 0; i < count; i++) {
+                       bt_put(notifs[i]);
+               }
+
+               break;
        case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
                ret = BT_COMPONENT_STATUS_AGAIN;
                goto end;
        case BT_NOTIFICATION_ITERATOR_STATUS_END:
                ret = BT_COMPONENT_STATUS_END;
                goto end;
+       case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
+               ret = BT_COMPONENT_STATUS_ERROR;
+               goto end;
        default:
                break;
        }
 
 end:
-       bt_put(notif);
        return ret;
 }
This page took 0.02621 seconds and 4 git commands to generate.