lib: notification iterator: transfer a batch of notifications
[babeltrace.git] / plugins / text / pretty / pretty.c
index 8b5ecd2c63a14bbd1681da21bde951c338b763f1..1010917d09faada2fa8ef6510b53f3fc8f1bed4b 100644 (file)
@@ -179,11 +179,13 @@ BT_HIDDEN
 enum bt_component_status pretty_consume(struct bt_private_component *component)
 {
        enum bt_component_status ret;
-       struct bt_notification *notification = NULL;
+       bt_notification_array notifs;
        struct bt_notification_iterator *it;
        struct pretty_component *pretty =
                bt_private_component_get_user_data(component);
        enum bt_notification_iterator_status it_ret;
+       uint64_t count = 0;
+       uint64_t i = 0;
 
        if (unlikely(pretty->error)) {
                ret = BT_COMPONENT_STATUS_ERROR;
@@ -191,7 +193,8 @@ enum bt_component_status pretty_consume(struct bt_private_component *component)
        }
 
        it = pretty->input_iterator;
-       it_ret = bt_notification_iterator_next(it);
+       it_ret = bt_private_connection_notification_iterator_next(it, &notifs,
+               &count);
 
        switch (it_ret) {
        case BT_NOTIFICATION_ITERATOR_STATUS_END:
@@ -208,12 +211,22 @@ enum bt_component_status pretty_consume(struct bt_private_component *component)
                goto end;
        }
 
-       notification = bt_notification_iterator_get_notification(it);
-       BT_ASSERT(notification);
-       ret = handle_notification(pretty, notification);
+       BT_ASSERT(it_ret == BT_NOTIFICATION_ITERATOR_STATUS_OK);
+
+       for (i = 0; i < count; i++) {
+               ret = handle_notification(pretty, notifs[i]);
+               if (ret) {
+                       goto end;
+               }
+
+               bt_put(notifs[i]);
+       }
 
 end:
-       bt_put(notification);
+       for (; i < count; i++) {
+               bt_put(notifs[i]);
+       }
+
        return ret;
 }
 
@@ -246,7 +259,7 @@ bt_bool check_param_exists(const char *key, struct bt_value *object, void *data)
        struct pretty_component *pretty = data;
        struct bt_value *plugin_opt_map = pretty->plugin_opt_map;
 
-       if (!bt_value_map_get(plugin_opt_map, key)) {
+       if (!bt_value_map_has_key(plugin_opt_map, key)) {
                fprintf(pretty->err,
                        "[warning] Parameter \"%s\" unknown to \"text.pretty\" sink component\n", key);
        }
@@ -263,7 +276,7 @@ enum bt_component_status apply_one_string(const char *key,
        enum bt_value_status status;
        const char *str;
 
-       value = bt_value_map_get(params, key);
+       value = bt_value_map_borrow(params, key);
        if (!value) {
                goto end;
        }
@@ -280,7 +293,6 @@ enum bt_component_status apply_one_string(const char *key,
        }
        *option = g_strdup(str);
 end:
-       bt_put(value);
        return ret;
 }
 
@@ -295,7 +307,7 @@ enum bt_component_status apply_one_bool(const char *key,
        enum bt_value_status status;
        bt_bool bool_val;
 
-       value = bt_value_map_get(params, key);
+       value = bt_value_map_borrow(params, key);
        if (!value) {
                goto end;
        }
@@ -311,8 +323,8 @@ enum bt_component_status apply_one_bool(const char *key,
        if (found) {
                *found = true;
        }
+
 end:
-       bt_put(value);
        return ret;
 }
 
@@ -378,7 +390,7 @@ enum bt_component_status apply_params(struct pretty_component *pretty,
                struct bt_value *color_value;
                const char *color;
 
-               color_value = bt_value_map_get(params, "color");
+               color_value = bt_value_map_borrow(params, "color");
                if (!color_value) {
                        goto end;
                }
@@ -397,8 +409,6 @@ enum bt_component_status apply_params(struct pretty_component *pretty,
                                warn_wrong_color_param(pretty);
                        }
                }
-
-               bt_put(color_value);
        }
 
        ret = apply_one_string("path", params, &pretty->options.output_path);
This page took 0.026164 seconds and 4 git commands to generate.