Add built-in colander sink component class
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 4 Aug 2017 23:07:24 +0000 (19:07 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 21 Aug 2017 21:02:22 +0000 (17:02 -0400)
commit361ac4a672191fd6a0642ace9724a393834f5634
treeae97174d86927019c12ab149a7de76b6f85bd2fb
parentc22a6d2dbcab993e6a7aaccd9d73d5d20eb4a28e
Add built-in colander sink component class

You can use this new built-in sink component class to create a component
which passes the consumed notification to the user through a pointer
passed as the initialization method data:

    struct bt_notification *notif = NULL;
    struct bt_component_class *colander_cc =
        bt_component_class_sink_colander_get();
    struct bt_component *colander_comp;

    ret = bt_graph_add_component_with_init_method_data(graph,
        colander_cc, "colander", NULL, &notif, &colander_comp);

    ...

    for (;;) {
        ret = bt_graph_consume(graph);
        if (ret != BT_GRAPH_STATUS_OK) {
            ...
        }

        /* Do something with notif */
        BT_PUT(notif);
    }

Everytime you call bt_graph_consume() and this function is successful,
your notification pointer contains a reference to the consumed
notification. You need to release this reference with bt_put(), as the
colander component won't do it. This is why you should not use
bt_graph_run() with a colander component because notifications will
leak.

bt_component_class_sink_colander_get() lazily creates the component
class the first time it is called and the uses this same reference for
future calls. The source file's destructor releases the global reference
when the library is destroyed.

The component class is built-in so that you do not need any installed
plugins to use this utility. Since it's not part of a plugin, you cannot
use it with the CLI, but this is okay because it needs custom
initialization method data anyway.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/Makefile.am
include/babeltrace/babeltrace.h
include/babeltrace/graph/component-class-sink-colander.h [new file with mode: 0644]
include/babeltrace/graph/component-class-sink.h
lib/graph/Makefile.am
lib/graph/component-class-sink-colander.c [new file with mode: 0644]
This page took 0.047592 seconds and 4 git commands to generate.