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>
Fri, 11 Aug 2017 22:54:16 +0000 (18:54 -0400)
commit706a18f9d5d66f764b864085768dde24d342d308
treed7a7e9a7cf70941fa1a3079144ab0b8df62877bc
parent4581096d7c66be8cb9dcba9c48aa458583f4de4a
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.024971 seconds and 4 git commands to generate.