lib: graph: remove useless checks, make functions inline on fast path
[babeltrace.git] / include / babeltrace / graph / component-sink-internal.h
index 34c899c15ec5bbb94f606ed5ecc028e1a1614786..3840bd509ae36356a54442d5c639802adf658bb6 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/compiler-internal.h>
 #include <babeltrace/graph/component-sink.h>
 #include <babeltrace/graph/component-internal.h>
 #include <babeltrace/graph/component-class-internal.h>
@@ -54,14 +55,31 @@ struct bt_component *bt_component_sink_create(
 BT_HIDDEN
 void bt_component_sink_destroy(struct bt_component *component);
 
-/**
- * Process one event, consuming from sources as needed.
- *
- * @param component    Component instance
- * @returns            One of #bt_component_status values
- */
-BT_HIDDEN
+static inline
 enum bt_component_status bt_component_sink_consume(
-               struct bt_component *component);
+               struct bt_component *component)
+{
+       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       struct bt_component_class_sink *sink_class = NULL;
+
+       BT_ASSERT(component);
+       BT_ASSERT(bt_component_get_class_type(component) ==
+               BT_COMPONENT_CLASS_TYPE_SINK);
+       sink_class = container_of(component->class,
+               struct bt_component_class_sink, parent);
+       BT_ASSERT(sink_class->methods.consume);
+       BT_LOGD("Calling user's consume method: "
+               "comp-addr=%p, comp-name=\"%s\"",
+               component, bt_component_get_name(component));
+       ret = sink_class->methods.consume(
+               bt_private_component_from_component(component));
+       BT_LOGD("User method returned: status=%s",
+               bt_component_status_string(ret));
+       if (ret < 0) {
+               BT_LOGW_STR("Consume method failed.");
+       }
+
+       return ret;
+}
 
 #endif /* BABELTRACE_GRAPH_COMPONENT_SINK_INTERNAL_H */
This page took 0.022839 seconds and 4 git commands to generate.