babeltrace/graph/notification-discarded-events.h \
babeltrace/graph/notification-discarded-packets.h \
babeltrace/graph/notification-event.h \
- babeltrace/graph/notification-heap.h \
babeltrace/graph/notification-inactivity.h \
babeltrace/graph/notification-iterator.h \
babeltrace/graph/notification-packet.h \
babeltrace/graph/graph-internal.h \
babeltrace/graph/component-class-sink-colander-internal.h \
babeltrace/graph/notification-inactivity-internal.h \
- babeltrace/graph/notification-heap-internal.h \
babeltrace/graph/component-source-internal.h \
babeltrace/graph/notification-discarded-elements-internal.h \
babeltrace/graph/notification-packet-internal.h \
#include <babeltrace/graph/notification-discarded-events.h>
#include <babeltrace/graph/notification-discarded-packets.h>
#include <babeltrace/graph/notification-event.h>
-#include <babeltrace/graph/notification-heap.h>
#include <babeltrace/graph/notification-inactivity.h>
#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/graph/notification-packet.h>
bool initialized;
};
-static inline
-struct bt_component *bt_component_borrow_from_private(
- struct bt_private_component *private_component)
-{
- return (void *) private_component;
-}
-
static inline
struct bt_private_component *bt_private_component_from_component(
struct bt_component *component)
return (void *) component;
}
-static inline
-struct bt_graph *bt_component_borrow_graph(struct bt_component *comp)
-{
- BT_ASSERT(comp);
- return (void *) comp->base.parent;
-}
-
BT_HIDDEN
enum bt_component_status bt_component_create(
struct bt_component_class *component_class,
/* For bt_bool */
#include <babeltrace/types.h>
+/* For bt_get */
+#include <babeltrace/ref.h>
+
#ifdef __cplusplus
extern "C" {
#endif
BT_COMPONENT_CLASS_TYPE_SINK;
}
-extern struct bt_graph *bt_component_get_graph(struct bt_component *component);
+extern struct bt_graph *bt_component_borrow_graph(struct bt_component *component);
+
+static inline
+struct bt_graph *bt_component_get_graph(struct bt_component *component)
+{
+ return bt_get(bt_component_borrow_graph(component));
+}
#ifdef __cplusplus
}
GPtrArray *iterators;
};
-static inline
-struct bt_connection *bt_connection_borrow_from_private(
- struct bt_private_connection *private_connection)
-{
- return (void *) private_connection;
-}
-
static inline
struct bt_private_connection *bt_private_connection_from_connection(
struct bt_connection *connection)
#include <babeltrace/graph/graph.h>
#include <babeltrace/graph/component-status.h>
+#include <babeltrace/graph/notification.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/object-internal.h>
+#include <babeltrace/object-pool-internal.h>
#include <babeltrace/assert-internal.h>
#include <stdlib.h>
#include <glib.h>
GArray *ports_connected;
GArray *ports_disconnected;
} listeners;
+
+ /* Pool of `struct bt_notification_event *` */
+ struct bt_object_pool event_notif_pool;
+
+ /* Pool of `struct bt_notification_packet_begin *` */
+ struct bt_object_pool packet_begin_notif_pool;
+
+ /* Pool of `struct bt_notification_packet_end *` */
+ struct bt_object_pool packet_end_notif_pool;
+
+ /*
+ * Array of `struct bt_notification *` (weak).
+ *
+ * This is an array of all the notifications ever created from
+ * this graph. Some of them can be in one of the pools above,
+ * some of them can be at large. Because each notification has a
+ * weak pointer to the graph containing its pool, we need to
+ * notify each notification that the graph is gone on graph
+ * destruction.
+ *
+ * TODO: When we support a maximum size for object pools,
+ * add a way for a notification to remove itself from this
+ * array (on destruction).
+ */
+ GPtrArray *notifications;
};
static inline
int bt_graph_remove_unconnected_component(struct bt_graph *graph,
struct bt_component *component);
+BT_HIDDEN
+void bt_graph_add_notification(struct bt_graph *graph,
+ struct bt_notification *notif);
+
static inline
const char *bt_graph_status_string(enum bt_graph_status status)
{
struct bt_connection;
struct bt_component;
struct bt_component_class;
+struct bt_value;
enum bt_graph_status {
BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION = 111,
BT_HIDDEN
struct bt_notification *bt_notification_discarded_elements_create(
+ struct bt_graph *graph,
enum bt_notification_type type,
struct bt_stream *stream,
struct bt_clock_value *begin_clock_value,
*/
#include <babeltrace/compiler-internal.h>
+#include <babeltrace/ctf-ir/event-class.h>
#include <babeltrace/ctf-ir/event.h>
#include <babeltrace/graph/notification-internal.h>
#include <babeltrace/graph/clock-class-priority-map.h>
struct bt_clock_class_priority_map *cc_prio_map;
};
+BT_HIDDEN
+struct bt_notification *bt_notification_event_new(struct bt_graph *graph);
+
+BT_HIDDEN
+void bt_notification_event_recycle(struct bt_notification *notif);
+
+BT_HIDDEN
+void bt_notification_event_destroy(struct bt_notification *notif);
+
#ifdef __cplusplus
}
#endif
struct bt_event_class;
struct bt_clock_class_priority_map;
-extern struct bt_notification *bt_notification_event_create(
+extern
+struct bt_notification *bt_notification_event_create(struct bt_graph *graph,
struct bt_event_class *event_class,
struct bt_packet *packet,
struct bt_clock_class_priority_map *clock_class_priority_map);
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_NOTIFICATION_HEAP_INTERNAL_H
-#define BABELTRACE_GRAPH_NOTIFICATION_HEAP_INTERNAL_H
-
-/*
- * Babeltrace - CTF notification heap priority heap
- *
- * Copyright (c) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <babeltrace/object-internal.h>
-#include <babeltrace/graph/notification-heap.h>
-#include <babeltrace/graph/notification.h>
-#include <glib.h>
-
-struct bt_notification_heap {
- struct bt_object base;
- GPtrArray *ptrs;
- size_t count;
- bt_notification_time_compare_func compare;
- void *compare_data;
-};
-
-#endif /* BABELTRACE_GRAPH_NOTIFICATION_HEAP_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_NOTIFICATION_HEAP_H
-#define BABELTRACE_GRAPH_NOTIFICATION_HEAP_H
-
-/*
- * Babeltrace - Notification Heap
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (c) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stddef.h>
-
-/* For bt_bool */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_notification;
-
-/**
- * bt_notification_time_compare - Compare two notifications' timestamps
- *
- * Compare two notifications in the time domain. Return true if 'a' happened
- * prior to 'b'. In the case where both notifications are deemed to have
- * happened at the same time, an implementation-defined critarion shall be
- * used to order the notifications. This criterion shall ensure a consistent
- * ordering over multiple runs.
- */
-typedef bt_bool (*bt_notification_time_compare_func)(
- struct bt_notification *a, struct bt_notification *b,
- void *user_data);
-
-/**
- * bt_notification_heap_create - create a new bt_notification heap.
- *
- * @comparator: Function to use for notification comparisons.
- *
- * Returns a new notification heap, NULL on error.
- */
-extern struct bt_notification_heap *bt_notification_heap_create(
- bt_notification_time_compare_func comparator, void *user_data);
-
-/**
- * bt_notification_heap_insert - insert an element into the heap
- *
- * @heap: the heap to be operated on
- * @notification: the notification to add
- *
- * Insert a notification into the heap.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_notification_heap_insert(struct bt_notification_heap *heap,
- struct bt_notification *notification);
-
-/**
- * bt_notification_heap_peek - return the element on top of the heap.
- *
- * @heap: the heap to be operated on
- *
- * Returns the top element of the heap, without performing any modification
- * to the heap structure. Returns NULL if the heap is empty. The returned
- * notification must be bt_put() by the caller.
- */
-extern struct bt_notification *bt_notification_heap_peek(
- struct bt_notification_heap *heap);
-
-/**
- * bt_notification_heap_pop - remove the element sitting on top of the heap.
- * @heap: the heap to be operated on
- *
- * Returns the top element of the heap. The element is removed from the
- * heap. Returns NULL if the heap is empty. The returned notification must be
- * bt_put() by the caller.
- */
-extern struct bt_notification *bt_notification_heap_pop(
- struct bt_notification_heap *heap);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_NOTIFICATION_HEAP_H */
struct bt_clock_class_priority_map;
struct bt_clock_class;
-extern struct bt_notification *bt_notification_inactivity_create(
+extern
+struct bt_notification *bt_notification_inactivity_create(
+ struct bt_graph *graph,
struct bt_clock_class_priority_map *clock_class_priority_map);
extern struct bt_clock_class_priority_map *
#include <babeltrace/ref-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/object-internal.h>
+#include <babeltrace/graph/graph.h>
#include <babeltrace/graph/notification.h>
#include <babeltrace/ctf-ir/stream.h>
+#include <babeltrace/object-pool-internal.h>
#include <babeltrace/types.h>
typedef struct bt_stream *(*get_stream_func)(
struct bt_notification {
struct bt_object base;
enum bt_notification_type type;
- get_stream_func get_stream;
uint64_t seq_num;
bt_bool frozen;
+
+ /* Owned by this; keeps the graph alive while the notif. is alive */
+ struct bt_graph *graph;
};
#define BT_ASSERT_PRE_NOTIF_IS_TYPE(_notif, _type) \
BT_HIDDEN
void bt_notification_init(struct bt_notification *notification,
enum bt_notification_type type,
- bt_object_release_func release);
+ bt_object_release_func release,
+ struct bt_graph *graph);
+
+static inline
+void bt_notification_reset(struct bt_notification *notification)
+{
+ BT_ASSERT(notification);
+
+#ifdef BT_DEV_MODE
+ notification->frozen = BT_FALSE;
+ notification->seq_num = UINT64_C(-1);
+#endif
+}
+
+static inline
+struct bt_notification *bt_notification_create_from_pool(
+ struct bt_object_pool *pool, struct bt_graph *graph)
+{
+ struct bt_notification *notif = bt_object_pool_create_object(pool);
+
+ if (!notif) {
+#ifdef BT_LIB_LOGE
+ BT_LIB_LOGE("Cannot allocate one notification from notification pool: "
+ "%![pool-]+o, %![graph-]+g", pool, graph);
+#endif
+ goto error;
+ }
+
+ if (!notif->graph) {
+ notif->graph = graph;
+ }
+
+ goto end;
+
+error:
+ BT_PUT(notif);
-static inline void bt_notification_freeze(struct bt_notification *notification)
+end:
+ return notif;
+}
+
+static inline void _bt_notification_freeze(struct bt_notification *notification)
{
notification->frozen = BT_TRUE;
}
+BT_HIDDEN
+void bt_notification_unlink_graph(struct bt_notification *notif);
+
+#ifdef BT_DEV_MODE
+# define bt_notification_freeze _bt_notification_freeze
+#else
+# define bt_notification_freeze(_x)
+#endif /* BT_DEV_MODE */
+
static inline
const char *bt_notification_type_string(enum bt_notification_type type)
{
struct bt_component *upstream_component; /* Weak */
struct bt_port *upstream_port; /* Weak */
struct bt_connection *connection; /* Weak */
+ struct bt_graph *graph; /* Weak */
/*
* This hash table keeps the state of a stream as viewed by
iterator->current_notification = bt_get(notification);
}
-static inline
-struct bt_notification_iterator_private_connection *
-bt_private_connection_notification_iterator_borrow_from_private(
- struct bt_private_connection_private_notification_iterator *private_notification_iterator)
-{
- return (void *) private_notification_iterator;
-}
-
static inline
struct bt_private_connection_private_notification_iterator *
bt_private_connection_private_notification_iterator_from_notification_iterator(
struct bt_packet *packet;
};
+BT_HIDDEN
+struct bt_notification *bt_notification_packet_begin_new(
+ struct bt_graph *graph);
+BT_HIDDEN
+void bt_notification_packet_begin_recycle(struct bt_notification *notif);
+
+BT_HIDDEN
+void bt_notification_packet_begin_destroy(struct bt_notification *notif);
+
+BT_HIDDEN
+struct bt_notification *bt_notification_packet_end_new(struct bt_graph *graph);
+
+BT_HIDDEN
+void bt_notification_packet_end_recycle(struct bt_notification *notif);
+
+BT_HIDDEN
+void bt_notification_packet_end_destroy(struct bt_notification *notif);
+
#endif /* BABELTRACE_GRAPH_NOTIFICATION_PACKET_INTERNAL_H */
struct bt_notification;
struct bt_packet;
-extern struct bt_notification *bt_notification_packet_begin_create(
- struct bt_packet *packet);
+extern
+struct bt_notification *bt_notification_packet_begin_create(
+ struct bt_graph *graph, struct bt_packet *packet);
+
+extern
+struct bt_notification *bt_notification_packet_end_create(
+ struct bt_graph *graph, struct bt_packet *packet);
-extern struct bt_notification *bt_notification_packet_end_create(
- struct bt_packet *packet);
extern struct bt_packet *bt_notification_packet_begin_borrow_packet(
struct bt_notification *notification);
struct bt_notification;
struct bt_stream;
-extern struct bt_notification *bt_notification_stream_begin_create(
+extern
+struct bt_notification *bt_notification_stream_begin_create(
+ struct bt_graph *graph,
struct bt_stream *stream);
-extern struct bt_notification *bt_notification_stream_end_create(
+extern
+struct bt_notification *bt_notification_stream_end_create(
+ struct bt_graph *graph,
struct bt_stream *stream);
extern struct bt_stream *bt_notification_stream_begin_borrow_stream(
void *user_data;
};
-static inline
-struct bt_port *bt_port_borrow_from_private(
- struct bt_private_port *private_port)
-{
- return (void *) private_port;
-}
-
static inline
struct bt_private_port *bt_private_port_from_port(
struct bt_port *port)
struct bt_component;
struct bt_private_component;
-extern struct bt_component *bt_component_from_private(
+extern struct bt_component *bt_component_borrow_from_private(
struct bt_private_component *private_component);
extern void *bt_private_component_get_user_data(
struct bt_private_connection_private_notification_iterator;
extern struct bt_notification_iterator *
-bt_private_connection_notification_iterator_from_private(
+bt_private_connection_notification_iterator_borrow_from_private(
struct bt_private_connection_private_notification_iterator *private_notification_iterator);
extern struct bt_private_component *
extern void *bt_private_connection_private_notification_iterator_get_user_data(
struct bt_private_connection_private_notification_iterator *private_notification_iterator);
+extern struct bt_graph *bt_private_connection_private_notification_iterator_borrow_graph(
+ struct bt_private_connection_private_notification_iterator *private_notification_iterator);
+
#ifdef __cplusplus
}
#endif
struct bt_private_connection;
struct bt_notification_iterator;
-extern struct bt_connection *bt_connection_from_private(
+extern struct bt_connection *bt_connection_borrow_from_private(
struct bt_private_connection *private_connection);
extern enum bt_connection_status
struct bt_private_component;
struct bt_private_connection;
-struct bt_port *bt_port_from_private(struct bt_private_port *private_port);
+struct bt_port *bt_port_borrow_from_private(
+ struct bt_private_port *private_port);
extern struct bt_private_connection *bt_private_port_get_private_connection(
struct bt_private_port *private_port);
extern struct bt_private_component *bt_private_port_get_private_component(
*
* 4. Destroying an event makes it recycle its event header
* field to its stream class's event header field pool. But
- * said pool is already destroyed.
+ * said pool is already finalized.
*/
bt_stream_class_common_finalize(BT_TO_COMMON(stream_class));
bt_object_pool_finalize(&stream_class->event_header_field_pool);
g_free(component);
}
-struct bt_component *bt_component_from_private(
+struct bt_component *bt_component_borrow_from_private(
struct bt_private_component *private_component)
{
- return bt_get(bt_component_borrow_from_private(private_component));
+ return (void *) private_component;
}
enum bt_component_class_type bt_component_get_class_type(
bt_object_set_parent(component, graph ? &graph->base : NULL);
}
-struct bt_graph *bt_component_get_graph(
- struct bt_component *component)
+struct bt_graph *bt_component_borrow_graph(struct bt_component *component)
{
- return (struct bt_graph *) bt_object_get_parent(&component->base);
+ return (struct bt_graph *) bt_object_borrow_parent(&component->base);
}
static
bt_connection_try_remove_from_graph(connection);
}
-struct bt_connection *bt_connection_from_private(
+struct bt_connection *bt_connection_borrow_from_private(
struct bt_private_connection *private_connection)
{
- return bt_get(bt_connection_borrow_from_private(private_connection));
+ return (void *) private_connection;
}
BT_HIDDEN
#include <babeltrace/compiler-internal.h>
#include <babeltrace/values.h>
+#include <babeltrace/graph/private-component.h>
#include <babeltrace/graph/component-filter-internal.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/graph/component-source.h>
#include <babeltrace/graph/component-filter.h>
#include <babeltrace/graph/port.h>
+#include <babeltrace/graph/notification-internal.h>
+#include <babeltrace/graph/notification-event-internal.h>
+#include <babeltrace/graph/notification-packet-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/values.h>
call_remove_listeners(graph->listeners.ports_connected);
call_remove_listeners(graph->listeners.ports_disconnected);
+ if (graph->notifications) {
+ g_ptr_array_free(graph->notifications, TRUE);
+ }
+
if (graph->connections) {
BT_LOGD_STR("Destroying connections.");
g_ptr_array_free(graph->connections, TRUE);
}
+
if (graph->components) {
BT_LOGD_STR("Destroying components.");
g_ptr_array_free(graph->components, TRUE);
}
+
if (graph->sinks_to_consume) {
g_queue_free(graph->sinks_to_consume);
}
g_array_free(graph->listeners.ports_disconnected, TRUE);
}
+ bt_object_pool_finalize(&graph->event_notif_pool);
+ bt_object_pool_finalize(&graph->packet_begin_notif_pool);
+ bt_object_pool_finalize(&graph->packet_end_notif_pool);
g_free(graph);
}
+static
+void destroy_notification_event(struct bt_notification *notif,
+ struct bt_graph *graph)
+{
+ bt_notification_event_destroy(notif);
+}
+
+static
+void destroy_notification_packet_begin(struct bt_notification *notif,
+ struct bt_graph *graph)
+{
+ bt_notification_packet_begin_destroy(notif);
+}
+
+static
+void destroy_notification_packet_end(struct bt_notification *notif,
+ struct bt_graph *graph)
+{
+ bt_notification_packet_end_destroy(notif);
+}
+
+static
+void notify_notification_graph_is_destroyed(struct bt_notification *notif)
+{
+ bt_notification_unlink_graph(notif);
+}
+
struct bt_graph *bt_graph_create(void)
{
struct bt_graph *graph;
goto error;
}
+ ret = bt_object_pool_initialize(&graph->event_notif_pool,
+ (bt_object_pool_new_object_func) bt_notification_event_new,
+ (bt_object_pool_destroy_object_func) destroy_notification_event,
+ graph);
+ if (ret) {
+ BT_LOGE("Failed to initialize event notification pool: ret=%d",
+ ret);
+ goto error;
+ }
+
+ ret = bt_object_pool_initialize(&graph->packet_begin_notif_pool,
+ (bt_object_pool_new_object_func) bt_notification_packet_begin_new,
+ (bt_object_pool_destroy_object_func) destroy_notification_packet_begin,
+ graph);
+ if (ret) {
+ BT_LOGE("Failed to initialize packet beginning notification pool: ret=%d",
+ ret);
+ goto error;
+ }
+
+ ret = bt_object_pool_initialize(&graph->packet_end_notif_pool,
+ (bt_object_pool_new_object_func) bt_notification_packet_end_new,
+ (bt_object_pool_destroy_object_func) destroy_notification_packet_end,
+ graph);
+ if (ret) {
+ BT_LOGE("Failed to initialize packet end notification pool: ret=%d",
+ ret);
+ goto error;
+ }
+
+ graph->notifications = g_ptr_array_new_with_free_func(
+ (GDestroyNotify) notify_notification_graph_is_destroyed);
BT_LOGD("Created graph object: addr=%p", graph);
end:
graph->can_consume = init_can_consume;
return ret;
}
+
+BT_HIDDEN
+void bt_graph_add_notification(struct bt_graph *graph,
+ struct bt_notification *notif)
+{
+ BT_ASSERT(graph);
+ BT_ASSERT(notif);
+
+ /*
+ * It's okay not to take a reference because, when a
+ * notification's reference count drops to 0, either:
+ *
+ * * It is recycled back to one of this graph's pool.
+ * * It is destroyed because it doesn't have any link to any
+ * graph, which means the original graph is already destroyed.
+ */
+ g_ptr_array_add(graph->notifications, notif);
+}
iterator->upstream_component = upstream_comp;
iterator->upstream_port = upstream_port;
iterator->connection = connection;
+ iterator->graph = bt_component_borrow_graph(upstream_comp);
iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED;
BT_LOGD("Created notification iterator: "
"upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
void *bt_private_connection_private_notification_iterator_get_user_data(
struct bt_private_connection_private_notification_iterator *private_iterator)
{
- struct bt_notification_iterator_private_connection *iterator =
+ struct bt_notification_iterator_private_connection *iterator = (void *)
bt_private_connection_notification_iterator_borrow_from_private(private_iterator);
BT_ASSERT_PRE_NON_NULL(private_iterator, "Notification iterator");
struct bt_private_connection_private_notification_iterator *private_iterator,
void *data)
{
- struct bt_notification_iterator_private_connection *iterator =
+ struct bt_notification_iterator_private_connection *iterator = (void *)
bt_private_connection_notification_iterator_borrow_from_private(private_iterator);
BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
return BT_NOTIFICATION_ITERATOR_STATUS_OK;
}
+struct bt_graph *bt_private_connection_private_notification_iterator_borrow_graph(
+ struct bt_private_connection_private_notification_iterator *private_iterator)
+{
+ struct bt_notification_iterator_private_connection *iterator = (void *)
+ bt_private_connection_notification_iterator_borrow_from_private(
+ private_iterator);
+
+ BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
+ return iterator->graph;
+}
+
struct bt_notification *bt_notification_iterator_borrow_notification(
struct bt_notification_iterator *iterator)
{
}
struct bt_notification_iterator *
-bt_private_connection_notification_iterator_from_private(
+bt_private_connection_notification_iterator_borrow_from_private(
struct bt_private_connection_private_notification_iterator *private_notification_iterator)
{
- return bt_get(
- bt_private_connection_notification_iterator_borrow_from_private(
- private_notification_iterator));
+ return (void *) private_notification_iterator;
}
packet.c \
event.c \
stream.c \
- heap.c \
inactivity.c \
discarded-events.c \
discarded-packets.c \
BT_HIDDEN
struct bt_notification *bt_notification_discarded_elements_create(
+ struct bt_graph *graph,
enum bt_notification_type type,
struct bt_stream *stream,
struct bt_clock_value *begin_clock_value,
}
bt_notification_init(¬ification->parent, type,
- bt_notification_discarded_elements_destroy);
+ bt_notification_discarded_elements_destroy, NULL);
ret_notif = ¬ification->parent;
notification->stream = bt_get(stream);
notification->begin_clock_value = bt_get(begin_clock_value);
#include <babeltrace/ctf-ir/event-class-internal.h>
#include <babeltrace/ctf-ir/stream-class-internal.h>
#include <babeltrace/ctf-ir/trace.h>
+#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/graph/clock-class-priority-map.h>
#include <babeltrace/graph/clock-class-priority-map-internal.h>
#include <babeltrace/graph/notification-event-internal.h>
#include <stdbool.h>
#include <inttypes.h>
-static
-void bt_notification_event_destroy(struct bt_object *obj)
-{
- struct bt_notification_event *notification =
- (struct bt_notification_event *) obj;
-
- BT_LOGD("Destroying event notification: addr=%p", notification);
- BT_LOGD_STR("Recycling event.");
- bt_event_recycle(notification->event);
- notification->event = NULL;
- BT_LOGD_STR("Putting clock class priority map.");
- BT_PUT(notification->cc_prio_map);
- g_free(notification);
-}
-
BT_ASSERT_PRE_FUNC
static inline bool event_class_has_trace(struct bt_event_class *event_class)
{
return bt_stream_class_borrow_trace(stream_class) != NULL;
}
+BT_HIDDEN
+struct bt_notification *bt_notification_event_new(struct bt_graph *graph)
+{
+ struct bt_notification_event *notification = NULL;
+
+ notification = g_new0(struct bt_notification_event, 1);
+ if (!notification) {
+ BT_LOGE_STR("Failed to allocate one event notification.");
+ goto error;
+ }
+
+ bt_notification_init(¬ification->parent, BT_NOTIFICATION_TYPE_EVENT,
+ (bt_object_release_func) bt_notification_event_recycle, graph);
+ goto end;
+
+error:
+ BT_PUT(notification);
+
+end:
+ return (void *) notification;
+}
+
struct bt_notification *bt_notification_event_create(
+ struct bt_graph *graph,
struct bt_event_class *event_class,
struct bt_packet *packet,
struct bt_clock_class_priority_map *cc_prio_map)
BT_ASSERT_PRE(event_class_has_trace(event_class),
"Event class is not part of a trace: %!+E", event_class);
- notification = g_new0(struct bt_notification_event, 1);
+ notification = (void *) bt_notification_create_from_pool(
+ &graph->event_notif_pool, graph);
if (!notification) {
- BT_LOGE_STR("Failed to allocate one event notification.");
+ /* bt_notification_create_from_pool() logs errors */
goto error;
}
- bt_notification_init(¬ification->parent, BT_NOTIFICATION_TYPE_EVENT,
- bt_notification_event_destroy);
notification->event = bt_event_create(event_class, packet);
if (!notification->event) {
BT_LIB_LOGE("Cannot create event from event class: "
end:
bt_put(cc_prio_map);
- return ¬ification->parent;
+ return (void *) notification;
+}
+
+BT_HIDDEN
+void bt_notification_event_destroy(struct bt_notification *notif)
+{
+ struct bt_notification_event *event_notif = (void *) notif;
+
+ BT_LOGD("Destroying event notification: addr=%p", notif);
+
+ if (event_notif->event) {
+ BT_LOGD_STR("Recycling event.");
+ bt_event_recycle(event_notif->event);
+ }
+
+ BT_LOGD_STR("Putting clock class priority map.");
+ BT_PUT(event_notif->cc_prio_map);
+ g_free(notif);
+}
+
+BT_HIDDEN
+void bt_notification_event_recycle(struct bt_notification *notif)
+{
+ struct bt_notification_event *event_notif = (void *) notif;
+ struct bt_graph *graph;
+
+ BT_ASSERT(event_notif);
+
+ if (!notif->graph) {
+ bt_notification_event_destroy(notif);
+ return;
+ }
+
+ BT_LOGD("Recycling event notification: addr=%p", notif);
+ bt_notification_reset(notif);
+
+ if (event_notif->event) {
+ BT_LOGD_STR("Recycling event.");
+ bt_event_recycle(event_notif->event);
+ event_notif->event = NULL;
+ }
+
+ BT_PUT(event_notif->cc_prio_map);
+ graph = notif->graph;
+ notif->graph = NULL;
+ bt_object_pool_recycle_object(&graph->event_notif_pool, notif);
}
struct bt_event *bt_notification_event_borrow_event(
+++ /dev/null
-/*
- * Babeltrace - CTF notification priority heap
- *
- * Static-sized priority heap containing pointers. Based on CLRS,
- * chapter 6.
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (c) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stddef.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/graph/notification-heap-internal.h>
-#include <babeltrace/assert-internal.h>
-
-#ifdef DEBUG_HEAP
-static
-void check_heap(struct bt_notification_heap *heap)
-{
- size_t i;
-
- if (!heap->count) {
- return;
- }
-
- for (i = 1; i < heap->count; i++) {
- BT_ASSERT(!heap->compare(g_ptr_array_index(heap->ptrs, i),
- g_ptr_array_index(heap->ptrs, 0),
- heap->compare_data));
- }
-}
-#else
-void check_heap(struct bt_notification_heap *heap)
-{
-}
-#endif
-
-static
-size_t parent(size_t i)
-{
- return (i - 1) >> 1;
-}
-
-static
-size_t left(size_t i)
-{
- return (i << 1) + 1;
-}
-
-static
-size_t right(size_t i)
-{
- return (i << 1) + 2;
-}
-
-/*
- * Copy of heap->ptrs pointer is invalid after heap_grow.
- */
-static
-int heap_grow(struct bt_notification_heap *heap, size_t new_len)
-{
- size_t alloc_len;
-
- if (likely(heap->ptrs->len >= new_len)) {
- goto end;
- }
-
- alloc_len = max_t(size_t, new_len, heap->ptrs->len << 1);
- g_ptr_array_set_size(heap->ptrs, alloc_len);
-end:
- return 0;
-}
-
-static
-int heap_set_count(struct bt_notification_heap *heap, size_t new_count)
-{
- int ret = 0;
-
- ret = heap_grow(heap, new_count);
- if (unlikely(ret)) {
- goto end;
- }
- heap->count = new_count;
-end:
- return ret;
-}
-
-static
-void heapify(struct bt_notification_heap *heap, size_t i)
-{
- struct bt_notification **ptrs =
- (struct bt_notification **) heap->ptrs->pdata;
-
- for (;;) {
- void *tmp;
- size_t l, r, largest;
-
- l = left(i);
- r = right(i);
- if (l < heap->count && heap->compare(ptrs[l], ptrs[i],
- heap->compare_data)) {
- largest = l;
- } else {
- largest = i;
- }
- if (r < heap->count && heap->compare(ptrs[r], ptrs[largest],
- heap->compare_data)) {
- largest = r;
- }
- if (unlikely(largest == i)) {
- break;
- }
- tmp = ptrs[i];
- ptrs[i] = ptrs[largest];
- ptrs[largest] = tmp;
- i = largest;
- }
- check_heap(heap);
-}
-
-static
-struct bt_notification *heap_replace_max(struct bt_notification_heap *heap,
- struct bt_notification *notification)
-{
- struct bt_notification *res = NULL;
-
- if (unlikely(!heap->count)) {
- (void) heap_set_count(heap, 1);
- g_ptr_array_index(heap->ptrs, 0) = notification;
- check_heap(heap);
- goto end;
- }
-
- /* Replace the current max and heapify. */
- res = g_ptr_array_index(heap->ptrs, 0);
- g_ptr_array_index(heap->ptrs, 0) = notification;
- heapify(heap, 0);
-end:
- return res;
-}
-
-static
-void bt_notification_heap_destroy(struct bt_object *obj)
-{
- struct bt_notification_heap *heap = container_of(obj,
- struct bt_notification_heap, base);
-
- if (heap->ptrs) {
- size_t i;
-
- for (i = 0; i < heap->count; i++) {
- bt_put(g_ptr_array_index(heap->ptrs, i));
- }
- g_ptr_array_free(heap->ptrs, TRUE);
- }
- g_free(heap);
-}
-
-struct bt_notification_heap *bt_notification_heap_create(
- bt_notification_time_compare_func comparator, void *user_data)
-{
- struct bt_notification_heap *heap = NULL;
-
- if (!comparator) {
- goto end;
- }
-
- heap = g_new0(struct bt_notification_heap, 1);
- if (!heap) {
- goto end;
- }
-
- bt_object_init(&heap->base, bt_notification_heap_destroy);
- heap->ptrs = g_ptr_array_new();
- if (!heap->ptrs) {
- BT_PUT(heap);
- goto end;
- }
-
- heap->compare = comparator;
- heap->compare_data = user_data;
-end:
- return heap;
-}
-
-struct bt_notification *bt_notification_heap_peek(
- struct bt_notification_heap *heap)
-{
- check_heap(heap);
- return bt_get(likely(heap->count) ?
- g_ptr_array_index(heap->ptrs, 0) : NULL);
-}
-
-int bt_notification_heap_insert(struct bt_notification_heap *heap,
- struct bt_notification *notification)
-{
- int ret;
- size_t pos;
- struct bt_notification **ptrs;
-
- ret = heap_set_count(heap, heap->count + 1);
- if (unlikely(ret)) {
- goto end;
- }
-
- ptrs = (struct bt_notification **) heap->ptrs->pdata;
- pos = heap->count - 1;
- while (pos > 0 && heap->compare(notification, ptrs[parent(pos)],
- heap->compare_data)) {
- /* Move parent down until we find the right spot. */
- ptrs[pos] = ptrs[parent(pos)];
- pos = parent(pos);
- }
- ptrs[pos] = bt_get(notification);
- check_heap(heap);
-end:
- return ret;
-}
-
-struct bt_notification *bt_notification_heap_pop(
- struct bt_notification_heap *heap)
-{
- struct bt_notification *ret = NULL;
-
- switch (heap->count) {
- case 0:
- goto end;
- case 1:
- (void) heap_set_count(heap, 0);
- ret = g_ptr_array_index(heap->ptrs, 0);
- goto end;
- }
- /*
- * Shrink, replace the current max by previous last entry and heapify.
- */
- heap_set_count(heap, heap->count - 1);
- /* count changed. previous last entry is at heap->count. */
- ret = heap_replace_max(heap, g_ptr_array_index(heap->ptrs,
- heap->count));
-end:
- /*
- * Not taking a supplementary reference since we are relinquishing our
- * own to the caller.
- */
- return ret;
-}
}
struct bt_notification *bt_notification_inactivity_create(
+ struct bt_graph *graph,
struct bt_clock_class_priority_map *cc_prio_map)
{
struct bt_notification_inactivity *notification;
}
bt_notification_init(¬ification->parent,
BT_NOTIFICATION_TYPE_INACTIVITY,
- bt_notification_inactivity_destroy);
+ bt_notification_inactivity_destroy, NULL);
ret_notif = ¬ification->parent;
notification->clock_values = g_hash_table_new_full(g_direct_hash,
g_direct_equal, NULL, (GDestroyNotify) bt_clock_value_recycle);
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/graph/notification-internal.h>
+#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/assert-pre-internal.h>
BT_ASSERT_PRE_FUNC
static inline void _init_seq_num(struct bt_notification *notification)
{
- notification->seq_num = -1ULL;
+ notification->seq_num = UINT64_C(-1);
}
#ifdef BT_DEV_MODE
BT_HIDDEN
void bt_notification_init(struct bt_notification *notification,
enum bt_notification_type type,
- bt_object_release_func release)
+ bt_object_release_func release,
+ struct bt_graph *graph)
{
BT_ASSERT(type >= 0 && type < BT_NOTIFICATION_TYPE_NR);
notification->type = type;
init_seq_num(notification);
bt_object_init(¬ification->base, release);
+ notification->graph = graph;
+
+ if (graph) {
+ bt_graph_add_notification(graph, notification);
+ }
}
enum bt_notification_type bt_notification_get_type(
BT_ASSERT_PRE_NON_NULL(notification, "Notification");
return notification->type;
}
+
+BT_HIDDEN
+void bt_notification_unlink_graph(struct bt_notification *notif)
+{
+ BT_ASSERT(notif);
+ notif->graph = NULL;
+}
#include <babeltrace/ctf-ir/stream-class.h>
#include <babeltrace/ctf-ir/stream.h>
#include <babeltrace/ctf-ir/stream-internal.h>
+#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/graph/notification-packet-internal.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/assert-pre-internal.h>
#include <inttypes.h>
-static
-void bt_notification_packet_begin_destroy(struct bt_object *obj)
+BT_HIDDEN
+struct bt_notification *bt_notification_packet_begin_new(struct bt_graph *graph)
{
- struct bt_notification_packet_begin *notification =
- (struct bt_notification_packet_begin *) obj;
+ struct bt_notification_packet_begin *notification;
- BT_LOGD("Destroying packet beginning notification: addr=%p",
- notification);
- BT_LOGD_STR("Putting packet.");
- BT_PUT(notification->packet);
- g_free(notification);
-}
+ notification = g_new0(struct bt_notification_packet_begin, 1);
+ if (!notification) {
+ BT_LOGE_STR("Failed to allocate one packet beginning notification.");
+ goto error;
+ }
-static
-void bt_notification_packet_end_destroy(struct bt_object *obj)
-{
- struct bt_notification_packet_end *notification =
- (struct bt_notification_packet_end *) obj;
+ bt_notification_init(¬ification->parent,
+ BT_NOTIFICATION_TYPE_PACKET_BEGIN,
+ (bt_object_release_func) bt_notification_packet_begin_recycle,
+ graph);
+ goto end;
- BT_LOGD("Destroying packet end notification: addr=%p",
- notification);
- BT_LOGD_STR("Putting packet.");
- BT_PUT(notification->packet);
- g_free(notification);
+error:
+ BT_PUT(notification);
+
+end:
+ return (void *) notification;
}
struct bt_notification *bt_notification_packet_begin_create(
- struct bt_packet *packet)
+ struct bt_graph *graph, struct bt_packet *packet)
{
struct bt_notification_packet_begin *notification;
struct bt_stream *stream;
stream_class,
bt_stream_class_get_name(stream_class),
bt_stream_class_get_id(stream_class));
- notification = g_new0(struct bt_notification_packet_begin, 1);
+ notification = (void *) bt_notification_create_from_pool(
+ &graph->packet_begin_notif_pool, graph);
if (!notification) {
- BT_LOGE_STR("Failed to allocate one packet beginning notification.");
+ /* bt_notification_create_from_pool() logs errors */
goto error;
}
- bt_notification_init(¬ification->parent,
- BT_NOTIFICATION_TYPE_PACKET_BEGIN,
- bt_notification_packet_begin_destroy);
notification->packet = bt_get(packet);
BT_LOGD("Created packet beginning notification object: "
"packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
stream_class,
bt_stream_class_get_name(stream_class),
bt_stream_class_get_id(stream_class), notification);
- return ¬ification->parent;
+ goto end;
+
error:
- return NULL;
+ BT_PUT(notification);
+
+end:
+ return (void *) notification;
+}
+
+BT_HIDDEN
+void bt_notification_packet_begin_destroy(struct bt_notification *notif)
+{
+ struct bt_notification_packet_begin *packet_begin_notif = (void *) notif;
+
+ BT_LOGD("Destroying packet beginning notification: addr=%p", notif);
+ BT_LOGD_STR("Putting packet.");
+ BT_PUT(packet_begin_notif->packet);
+ g_free(notif);
+}
+
+BT_HIDDEN
+void bt_notification_packet_begin_recycle(struct bt_notification *notif)
+{
+ struct bt_notification_packet_begin *packet_begin_notif = (void *) notif;
+ struct bt_graph *graph;
+
+ BT_ASSERT(packet_begin_notif);
+
+ if (!notif->graph) {
+ bt_notification_packet_begin_destroy(notif);
+ return;
+ }
+
+ BT_LOGD("Recycling packet beginning notification: addr=%p", notif);
+ bt_notification_reset(notif);
+ BT_PUT(packet_begin_notif->packet);
+ graph = notif->graph;
+ notif->graph = NULL;
+ bt_object_pool_recycle_object(&graph->packet_begin_notif_pool, notif);
}
struct bt_packet *bt_notification_packet_begin_borrow_packet(
return packet_begin->packet;
}
+BT_HIDDEN
+struct bt_notification *bt_notification_packet_end_new(struct bt_graph *graph)
+{
+ struct bt_notification_packet_end *notification;
+
+ notification = g_new0(struct bt_notification_packet_end, 1);
+ if (!notification) {
+ BT_LOGE_STR("Failed to allocate one packet end notification.");
+ goto error;
+ }
+
+ bt_notification_init(¬ification->parent,
+ BT_NOTIFICATION_TYPE_PACKET_END,
+ (bt_object_release_func) bt_notification_packet_end_recycle,
+ graph);
+ goto end;
+
+error:
+ BT_PUT(notification);
+
+end:
+ return (void *) notification;
+}
+
struct bt_notification *bt_notification_packet_end_create(
- struct bt_packet *packet)
+ struct bt_graph *graph, struct bt_packet *packet)
{
struct bt_notification_packet_end *notification;
struct bt_stream *stream;
stream_class,
bt_stream_class_get_name(stream_class),
bt_stream_class_get_id(stream_class));
- notification = g_new0(struct bt_notification_packet_end, 1);
+ notification = (void *) bt_notification_create_from_pool(
+ &graph->packet_end_notif_pool, graph);
if (!notification) {
- BT_LOGE_STR("Failed to allocate one packet end notification.");
+ /* bt_notification_create_from_pool() logs errors */
goto error;
}
- bt_notification_init(¬ification->parent,
- BT_NOTIFICATION_TYPE_PACKET_END,
- bt_notification_packet_end_destroy);
notification->packet = bt_get(packet);
BT_LOGD("Created packet end notification object: "
"packet-addr=%p, stream-addr=%p, stream-name=\"%s\", "
stream_class,
bt_stream_class_get_name(stream_class),
bt_stream_class_get_id(stream_class), notification);
- return ¬ification->parent;
+ goto end;
+
error:
- return NULL;
+ BT_PUT(notification);
+
+end:
+ return (void *) notification;
+}
+
+BT_HIDDEN
+void bt_notification_packet_end_destroy(struct bt_notification *notif)
+{
+ struct bt_notification_packet_end *packet_end_notif = (void *) notif;
+
+ BT_LOGD("Destroying packet end notification: addr=%p", notif);
+ BT_LOGD_STR("Putting packet.");
+ BT_PUT(packet_end_notif->packet);
+ g_free(notif);
+}
+
+BT_HIDDEN
+void bt_notification_packet_end_recycle(struct bt_notification *notif)
+{
+ struct bt_notification_packet_end *packet_end_notif = (void *) notif;
+ struct bt_graph *graph;
+
+ BT_ASSERT(packet_end_notif);
+
+ if (!notif->graph) {
+ bt_notification_packet_end_destroy(notif);
+ return;
+ }
+
+ BT_LOGD("Recycling packet end notification: addr=%p", notif);
+ bt_notification_reset(notif);
+ BT_PUT(packet_end_notif->packet);
+ graph = notif->graph;
+ notif->graph = NULL;
+ bt_object_pool_recycle_object(&graph->packet_end_notif_pool, notif);
}
struct bt_packet *bt_notification_packet_end_borrow_packet(
}
struct bt_notification *bt_notification_stream_end_create(
- struct bt_stream *stream)
+ struct bt_graph *graph, struct bt_stream *stream)
{
struct bt_notification_stream_end *notification;
struct bt_stream_class *stream_class;
bt_notification_init(¬ification->parent,
BT_NOTIFICATION_TYPE_STREAM_END,
- bt_notification_stream_end_destroy);
+ bt_notification_stream_end_destroy, NULL);
notification->stream = bt_get(stream);
BT_LOGD("Created stream end notification object: "
"stream-addr=%p, stream-name=\"%s\", "
}
struct bt_notification *bt_notification_stream_begin_create(
- struct bt_stream *stream)
+ struct bt_graph *graph, struct bt_stream *stream)
{
struct bt_notification_stream_begin *notification;
struct bt_stream_class *stream_class;
bt_notification_init(¬ification->parent,
BT_NOTIFICATION_TYPE_STREAM_BEGIN,
- bt_notification_stream_begin_destroy);
+ bt_notification_stream_begin_destroy, NULL);
notification->stream = bt_get(stream);
BT_LOGD("Created stream beginning notification object: "
"stream-addr=%p, stream-name=\"%s\", "
g_free(port);
}
-struct bt_port *bt_port_from_private(
+struct bt_port *bt_port_borrow_from_private(
struct bt_private_port *private_port)
{
- return bt_get(bt_port_borrow_from_private(private_port));
+ return (void *) private_port;
}
BT_HIDDEN
#include <babeltrace/compiler-internal.h>
#include <babeltrace/values.h>
+#include <babeltrace/graph/private-component.h>
#include <babeltrace/graph/component-sink-internal.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/notification.h>
#include <babeltrace/ref.h>
#include <babeltrace/compiler-internal.h>
+#include <babeltrace/graph/private-component.h>
#include <babeltrace/graph/component-source-internal.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/port-internal.h>
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/graph/notification-discarded-elements-internal.h>
#include <babeltrace/graph/notification-event-internal.h>
-#include <babeltrace/graph/notification-heap-internal.h>
#include <babeltrace/graph/notification-inactivity-internal.h>
#include <babeltrace/graph/notification-internal.h>
#include <babeltrace/graph/notification-iterator-internal.h>
SET_TMP_PREFIX("ehf-pool-");
format_object_pool(buf_ch, extended, prefix,
&stream_class->event_header_field_pool);
+ SET_TMP_PREFIX("pcf-pool-");
+ format_object_pool(buf_ch, extended, prefix,
+ &stream_class->packet_context_field_pool);
}
static inline void format_writer_stream_class(char **buf_ch, bool extended,
return;
}
- BUF_APPEND(", %sis-frozen=%d", PRFIELD(notif->frozen));
+ BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p",
+ PRFIELD(notif->frozen), PRFIELD(notif->graph));
switch (notif->type) {
case BT_NOTIFICATION_TYPE_EVENT:
static inline void format_graph(char **buf_ch, bool extended,
const char *prefix, struct bt_graph *graph)
{
+ char tmp_prefix[64];
+
BUF_APPEND(", %sis-canceled=%d", PRFIELD(graph->canceled));
if (!extended) {
BUF_APPEND(", %sconn-count=%u",
PRFIELD(graph->connections->len));
}
+
+ SET_TMP_PREFIX("en-pool-");
+ format_object_pool(buf_ch, extended, prefix,
+ &graph->event_notif_pool);
+ SET_TMP_PREFIX("pbn-pool-");
+ format_object_pool(buf_ch, extended, prefix,
+ &graph->packet_begin_notif_pool);
+ SET_TMP_PREFIX("pen-pool-");
+ format_object_pool(buf_ch, extended, prefix,
+ &graph->packet_end_notif_pool);
}
static inline void format_notification_iterator(char **buf_ch,
/* Visit stack */
struct stack *stack;
+ /* Current graph to create notifications (weak) */
+ struct bt_graph *graph;
+
/*
* Current dynamic scope field pointer.
*
notit, notit->meta.event_class,
bt_event_class_get_name(notit->meta.event_class),
notit->packet);
- notif = bt_notification_event_create(notit->meta.event_class,
- notit->packet, notit->meta.cc_prio_map);
+ BT_ASSERT(notit->graph);
+ notif = bt_notification_event_create(notit->graph,
+ notit->meta.event_class, notit->packet,
+ notit->meta.cc_prio_map);
if (!notif) {
BT_LOGE("Cannot create event notification: "
"notit-addr=%p, ec-addr=%p, ec-name=\"%s\", "
}
BT_ASSERT(notit->stream);
- ret = bt_notification_stream_begin_create(notit->stream);
+ BT_ASSERT(notit->graph);
+ ret = bt_notification_stream_begin_create(notit->graph, notit->stream);
if (!ret) {
BT_LOGE("Cannot create stream beginning notification: "
"notit-addr=%p, stream-addr=%p",
return;
}
- ret = bt_notification_stream_end_create(notit->stream);
+ BT_ASSERT(notit->graph);
+ ret = bt_notification_stream_end_create(notit->graph, notit->stream);
if (!ret) {
BT_LOGE("Cannot create stream beginning notification: "
"notit-addr=%p, stream-addr=%p",
notit->dscopes.stream_packet_context);
}
- notif = bt_notification_packet_begin_create(notit->packet);
+ BT_ASSERT(notit->graph);
+ notif = bt_notification_packet_begin_create(notit->graph,
+ notit->packet);
if (!notif) {
BT_LOGE("Cannot create packet beginning notification: "
"notit-addr=%p, packet-addr=%p",
return;
}
- notif = bt_notification_packet_end_create(notit->packet);
+ BT_ASSERT(notit->graph);
+ notif = bt_notification_packet_end_create(notit->graph, notit->packet);
if (!notif) {
BT_LOGE("Cannot create packet end notification: "
"notit-addr=%p, packet-addr=%p",
enum bt_notif_iter_status bt_notif_iter_get_next_notification(
struct bt_notif_iter *notit,
struct bt_clock_class_priority_map *cc_prio_map,
+ struct bt_graph *graph,
struct bt_notification **notification)
{
int ret;
BT_ASSERT(notit);
BT_ASSERT(notification);
+ if (notit->state == STATE_DONE) {
+ status = BT_NOTIF_ITER_STATUS_EOF;
+ goto end;
+ }
+
if (cc_prio_map != notit->meta.cc_prio_map) {
bt_put(notit->meta.cc_prio_map);
notit->meta.cc_prio_map = bt_get(cc_prio_map);
}
- if (notit->state == STATE_DONE) {
- status = BT_NOTIF_ITER_STATUS_EOF;
- goto end;
- }
+ notit->graph = graph;
BT_LOGV("Getting next notification: notit-addr=%p, cc-prio-map-addr=%p",
notit, cc_prio_map);
enum bt_notif_iter_status bt_notif_iter_get_next_notification(
struct bt_notif_iter *notit,
struct bt_clock_class_priority_map *cc_prio_map,
+ struct bt_graph *graph,
struct bt_notification **notification);
/**
BT_HIDDEN
struct ctf_fs_ds_file *ctf_fs_ds_file_create(
struct ctf_fs_trace *ctf_fs_trace,
- struct bt_notif_iter *notif_iter,
+ struct bt_graph *graph, struct bt_notif_iter *notif_iter,
struct bt_stream *stream, const char *path)
{
int ret;
goto error;
}
+ ds_file->graph = graph;
ds_file->file = ctf_fs_file_create();
if (!ds_file->file) {
goto error;
};
notif_iter_status = bt_notif_iter_get_next_notification(
- ds_file->notif_iter, ds_file->cc_prio_map, &ret.notification);
+ ds_file->notif_iter, ds_file->cc_prio_map, ds_file->graph,
+ &ret.notification);
switch (notif_iter_status) {
case BT_NOTIF_ITER_STATUS_EOF:
};
struct ctf_fs_ds_file {
+ /* Weak */
+ struct bt_graph *graph;
+
/* Owned by this */
struct ctf_fs_file *file;
BT_HIDDEN
struct ctf_fs_ds_file *ctf_fs_ds_file_create(
struct ctf_fs_trace *ctf_fs_trace,
+ struct bt_graph *graph,
struct bt_notif_iter *notif_iter,
struct bt_stream *stream, const char *path);
ctf_fs_ds_file_destroy(notif_iter_data->ds_file);
notif_iter_data->ds_file = ctf_fs_ds_file_create(
notif_iter_data->ds_file_group->ctf_fs_trace,
+ notif_iter_data->graph,
notif_iter_data->notif_iter,
notif_iter_data->ds_file_group->stream,
ds_file_info->path->str);
goto error;
}
+ notif_iter_data->graph = bt_component_borrow_graph(
+ bt_component_borrow_from_private(port_data->ctf_fs->priv_comp));
notif_iter_data->notif_iter = bt_notif_iter_create(
port_data->ds_file_group->ctf_fs_trace->metadata->trace,
bt_common_get_page_size() * 8,
goto error;
}
+ port_data->ctf_fs = ctf_fs;
port_data->ds_file_group = ds_file_group;
ret = bt_private_component_source_add_output_private_port(
ctf_fs->priv_comp, port_name->str, port_data, NULL);
static
int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
- const char *path)
+ struct bt_graph *graph, const char *path)
{
struct bt_field *packet_header_field = NULL;
struct bt_field *packet_context_field = NULL;
goto error;
}
- ds_file = ctf_fs_ds_file_create(ctf_fs_trace, notif_iter, NULL, path);
+ ds_file = ctf_fs_ds_file_create(ctf_fs_trace, graph, notif_iter,
+ NULL, path);
if (!ds_file) {
goto error;
}
}
static
-int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
+int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace,
+ struct bt_graph *graph)
{
int ret = 0;
const char *basename;
continue;
}
- ret = add_ds_file_to_ds_file_group(ctf_fs_trace,
+ ret = add_ds_file_to_ds_file_group(ctf_fs_trace, graph,
file->path->str);
if (ret) {
BT_LOGE("Cannot add stream file `%s` to stream file group",
BT_HIDDEN
struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *name,
- struct ctf_fs_metadata_config *metadata_config)
+ struct ctf_fs_metadata_config *metadata_config,
+ struct bt_graph *graph)
{
struct ctf_fs_trace *ctf_fs_trace;
int ret;
goto error;
}
- ret = create_ds_file_groups(ctf_fs_trace);
+ ret = create_ds_file_groups(ctf_fs_trace, graph);
if (ret) {
goto error;
}
tn_node = g_list_next(tn_node)) {
GString *trace_path = tp_node->data;
GString *trace_name = tn_node->data;
+ struct bt_graph *graph = bt_component_borrow_graph(
+ bt_component_borrow_from_private(ctf_fs->priv_comp));
+ BT_ASSERT(graph);
ctf_fs_trace = ctf_fs_trace_create(trace_path->str,
- trace_name->str, &ctf_fs->metadata_config);
+ trace_name->str, &ctf_fs->metadata_config,
+ graph);
if (!ctf_fs_trace) {
BT_LOGE("Cannot create trace for `%s`.",
trace_path->str);
struct ctf_fs_port_data {
/* Weak, belongs to ctf_fs_trace */
struct ctf_fs_ds_file_group *ds_file_group;
+
+ /* Weak */
+ struct ctf_fs_component *ctf_fs;
};
struct ctf_fs_notif_iter_data {
+ /* Weak */
+ struct bt_graph *graph;
+
/* Weak, belongs to ctf_fs_trace */
struct ctf_fs_ds_file_group *ds_file_group;
BT_HIDDEN
struct ctf_fs_trace *ctf_fs_trace_create(const char *path, const char *name,
- struct ctf_fs_metadata_config *config);
+ struct ctf_fs_metadata_config *config, struct bt_graph *graph);
BT_HIDDEN
void ctf_fs_trace_destroy(struct ctf_fs_trace *trace);
goto end;
}
- trace = ctf_fs_trace_create(trace_path, trace_name, NULL);
+ trace = ctf_fs_trace_create(trace_path, trace_name, NULL, NULL);
if (!trace) {
BT_LOGE("Failed to create fs trace at \'%s\'", trace_path);
ret = -1;
bt_bool no_timestamp;
} params;
+ struct bt_graph *graph; /* Weak */
struct bt_trace *trace;
struct bt_stream_class *stream_class;
struct bt_event_class *event_class;
goto error;
}
+ dmesg_comp->graph = bt_component_borrow_graph(
+ bt_component_borrow_from_private(priv_comp));
+ BT_ASSERT(dmesg_comp->graph);
dmesg_comp->params.path = g_string_new(NULL);
if (!dmesg_comp->params.path) {
BT_LOGE_STR("Failed to allocate a GString.");
goto error;
}
- notif = bt_notification_event_create(dmesg_comp->event_class,
- dmesg_comp->packet, dmesg_comp->cc_prio_map);
+ notif = bt_notification_event_create(dmesg_comp->graph,
+ dmesg_comp->event_class, dmesg_comp->packet,
+ dmesg_comp->cc_prio_map);
if (!notif) {
BT_LOGE_STR("Cannot create event notification.");
goto error;
case STATE_EMIT_STREAM_BEGINNING:
BT_ASSERT(dmesg_notif_iter->tmp_event_notif);
next_ret.notification = bt_notification_stream_begin_create(
- dmesg_comp->stream);
+ dmesg_comp->graph, dmesg_comp->stream);
dmesg_notif_iter->state = STATE_EMIT_PACKET_BEGINNING;
break;
case STATE_EMIT_PACKET_BEGINNING:
BT_ASSERT(dmesg_notif_iter->tmp_event_notif);
next_ret.notification = bt_notification_packet_begin_create(
- dmesg_comp->packet);
+ dmesg_comp->graph, dmesg_comp->packet);
dmesg_notif_iter->state = STATE_EMIT_EVENT;
break;
case STATE_EMIT_EVENT:
break;
case STATE_EMIT_PACKET_END:
next_ret.notification = bt_notification_packet_end_create(
- dmesg_comp->packet);
+ dmesg_comp->graph, dmesg_comp->packet);
dmesg_notif_iter->state = STATE_EMIT_STREAM_END;
break;
case STATE_EMIT_STREAM_END:
next_ret.notification = bt_notification_stream_end_create(
- dmesg_comp->stream);
+ dmesg_comp->graph, dmesg_comp->stream);
dmesg_notif_iter->state = STATE_DONE;
break;
default:
struct bt_notification_iterator *create_notif_iter_on_input_port(
struct bt_private_port *priv_port, int *ret)
{
- struct bt_port *port = bt_port_from_private(priv_port);
+ struct bt_port *port = bt_port_borrow_from_private(priv_port);
struct bt_notification_iterator *notif_iter = NULL;
struct bt_private_connection *priv_conn = NULL;
enum bt_connection_status conn_status;
port, bt_port_get_name(port), priv_conn, notif_iter);
end:
- bt_put(port);
bt_put(priv_conn);
return notif_iter;
}
}
priv_port = node->data;
- port = bt_port_from_private(priv_port);
+ port = bt_port_borrow_from_private(priv_port);
BT_ASSERT(port);
if (!bt_port_is_connected(port)) {
goto remove_node;
}
- BT_PUT(port);
upstream_notif_iter = create_notif_iter_on_input_port(priv_port,
&ret);
if (ret) {
remove_node:
bt_put(upstream_notif_iter);
- bt_put(port);
muxer_notif_iter->newly_connected_priv_ports =
g_list_delete_link(
muxer_notif_iter->newly_connected_priv_ports,
* iterator's list of newly connected ports. They will be
* handled by muxer_notif_iter_handle_newly_connected_ports().
*/
- comp = bt_component_from_private(muxer_comp->priv_comp);
+ comp = bt_component_borrow_from_private(muxer_comp->priv_comp);
BT_ASSERT(comp);
count = bt_component_filter_get_input_port_count(comp);
if (count < 0) {
struct bt_port *port;
BT_ASSERT(priv_port);
- port = bt_port_from_private(priv_port);
+ port = bt_port_borrow_from_private(priv_port);
BT_ASSERT(port);
if (!bt_port_is_connected(port)) {
"muxer-comp-addr=%p, port-addr=%p, port-name\"%s\"",
muxer_comp, port, bt_port_get_name(port));
bt_put(priv_port);
- bt_put(port);
continue;
}
- bt_put(port);
bt_put(priv_port);
muxer_notif_iter->newly_connected_priv_ports =
g_list_append(
}
end:
- bt_put(comp);
return ret;
}
struct bt_port *other_port)
{
struct bt_port *self_port =
- bt_port_from_private(self_private_port);
+ bt_port_borrow_from_private(self_private_port);
struct muxer_comp *muxer_comp =
bt_private_component_get_user_data(priv_comp);
size_t i;
}
end:
- bt_put(self_port);
+ return;
}
BT_HIDDEN
void muxer_port_disconnected(struct bt_private_component *priv_comp,
struct bt_private_port *priv_port)
{
- struct bt_port *port = bt_port_from_private(priv_port);
+ struct bt_port *port = bt_port_borrow_from_private(priv_port);
struct muxer_comp *muxer_comp =
bt_private_component_get_user_data(priv_comp);
priv_comp, muxer_comp, port, bt_port_get_name(port),
muxer_comp->available_input_ports);
}
-
- bt_put(port);
}
lib/test_ctf_ir_ref \
lib/test_bt_ctf_field_type_validation \
lib/test_ir_visit \
- lib/test_bt_notification_heap \
lib/test_graph_topo \
lib/test_cc_prio_map \
lib/test_bt_notification_iterator
test_ir_visit_LDADD = $(COMMON_TEST_LDADD)
-test_bt_notification_heap_LDADD = $(COMMON_TEST_LDADD)
-
test_graph_topo_LDADD = $(COMMON_TEST_LDADD)
test_cc_prio_map_LDADD = $(COMMON_TEST_LDADD)
noinst_PROGRAMS = test_bitfield test_ctf_writer test_bt_values \
test_ctf_ir_ref test_bt_ctf_field_type_validation test_ir_visit \
- test_bt_notification_heap test_graph_topo \
- test_cc_prio_map test_bt_notification_iterator
+ test_graph_topo test_cc_prio_map test_bt_notification_iterator
test_bitfield_SOURCES = test_bitfield.c
test_ctf_writer_SOURCES = test_ctf_writer.c
test_ctf_ir_ref_SOURCES = test_ctf_ir_ref.c
test_bt_ctf_field_type_validation_SOURCES = test_bt_ctf_field_type_validation.c
test_ir_visit_SOURCES = test_ir_visit.c
-test_bt_notification_heap_SOURCES = test_bt_notification_heap.c
test_graph_topo_SOURCES = test_graph_topo.c
test_cc_prio_map_SOURCES = test_cc_prio_map.c
test_bt_notification_iterator_SOURCES = test_bt_notification_iterator.c
+++ /dev/null
-/*
- * test_bt_notification_heap.c
- *
- * bt_notification_heap tests
- *
- * Copyright 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; under version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "tap/tap.h"
-#include <stdlib.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
-#include <babeltrace/graph/notification-heap.h>
-#include <babeltrace/graph/notification.h>
-#include <babeltrace/graph/notification-internal.h>
-
-#define NR_TESTS 7
-
-struct dummy_notification {
- struct bt_notification parent;
- uint64_t value;
-};
-
-static
-void dummy_notification_destroy(struct bt_object *obj)
-{
- g_free(obj);
-}
-
-/* Reproduced from internal notification.c code. */
-void bt_notification_init(struct bt_notification *notification,
- enum bt_notification_type type,
- bt_object_release_func release)
-{
- assert(type > 0 && type < BT_NOTIFICATION_TYPE_NR);
- notification->type = type;
- bt_object_init(¬ification->base, release);
-}
-
-static
-struct bt_notification *dummy_notification_create(uint64_t value)
-{
- struct dummy_notification *notification;
-
- notification = g_new0(struct dummy_notification, 1);
- if (!notification) {
- goto error;
- }
- bt_notification_init(¬ification->parent,
- BT_NOTIFICATION_TYPE_NR - 1 /* dummy value */,
- dummy_notification_destroy);
- notification->value = value;
- return ¬ification->parent;
-error:
- return NULL;
-}
-
-static
-bt_bool compare_notifications(struct bt_notification *a, struct bt_notification *b,
- void *unused)
-{
- uint64_t val_a = ((struct dummy_notification *) a)->value;
- uint64_t val_b = ((struct dummy_notification *) b)->value;
-
- if (val_a == val_b) {
- return a < b;
- } else {
- return val_a < val_b;
- }
-}
-
-int main(int argc, char **argv)
-{
- int i;
- uint64_t last_read_value = 0;
- struct bt_notification_heap *heap = NULL;
-
- /* Initialize tap harness before any tests */
- plan_tests(NR_TESTS);
- heap = bt_notification_heap_create(compare_notifications, NULL);
- ok(heap, "Created a notification heap");
-
- /* Insert 10 000 notifications with random values. */
- for (i = 0; i < 10000; i++) {
- int ret;
- struct bt_notification *notification =
- dummy_notification_create(rand());
-
- if (!notification) {
- diag("Dummy notification creation failed");
- goto end;
- }
-
- ret = bt_notification_heap_insert(heap, notification);
- if (ret) {
- diag("Failed to insert notification %i in heap", i);
- goto end;
- }
- bt_put(notification);
- }
- pass("Inserted 10 000 random notifications in notification heap");
-
- /* Pop 5000 notifications, making sure the values read are ascending */
- for (i = 0; i < 5000; i++) {
- struct bt_notification *pop_notification;
- struct bt_notification *peek_notification;
- struct dummy_notification *dummy;
-
- peek_notification = bt_notification_heap_peek(heap);
- if (!peek_notification) {
- fail("Failed to peek a notification");
- goto end;
- }
-
- pop_notification = bt_notification_heap_pop(heap);
- if (!pop_notification) {
- fail("Failed to pop a notification");
- goto end;
- }
-
- if (peek_notification != pop_notification) {
- fail("bt_notification_heap_peek and bt_notification_heap_pop do not return the same notification");
- bt_put(peek_notification);
- bt_put(pop_notification);
- goto end;
- }
-
- dummy = container_of(pop_notification,
- struct dummy_notification, parent);
- if (dummy->value < last_read_value) {
- fail("Notification heap did not provide notifications in ascending order");
- }
- last_read_value = dummy->value;
- bt_put(peek_notification);
- bt_put(pop_notification);
- }
-
- pass("bt_notification_heap_peek and bt_notification_heap_pop return the same notification");
- pass("Notification heap provided 5 000 notifications in ascending order");
-
- /* Insert 10 000 notifications with random values. */
- for (i = 0; i < 10000; i++) {
- int ret;
- struct bt_notification *notification =
- dummy_notification_create(rand());
-
- if (!notification) {
- diag("Dummy notification creation failed");
- goto end;
- }
-
- ret = bt_notification_heap_insert(heap, notification);
- if (ret) {
- diag("Failed to insert notification %i in heap", i);
- goto end;
- }
- bt_put(notification);
- }
- pass("Inserted 10 000 random notifications in notification heap after popping");
-
- last_read_value = 0;
- /* Pop remaining 15 000 notifications, making sure the values read are ascending */
- for (i = 0; i < 15000; i++) {
- struct bt_notification *pop_notification;
- struct dummy_notification *dummy;
-
- pop_notification = bt_notification_heap_pop(heap);
- if (!pop_notification) {
- fail("Failed to pop a notification");
- goto end;
- }
- dummy = container_of(pop_notification,
- struct dummy_notification, parent);
- if (dummy->value < last_read_value) {
- fail("Notification heap did not provide notifications in ascending order");
- }
- last_read_value = dummy->value;
- bt_put(pop_notification);
- }
- pass("Popped remaining 15 000 notifications from heap in ascending order");
-
- ok(!bt_notification_heap_peek(heap), "No notifications left in heap");
-end:
- bt_put(heap);
- return exit_status();
-}
static bool debug = false;
static enum test current_test;
static GArray *test_events;
+static struct bt_graph *graph;
static struct bt_clock_class_priority_map *src_empty_cc_prio_map;
static struct bt_stream_class *src_stream_class;
static struct bt_event_class *src_event_class;
break;
case SEQ_INACTIVITY:
next_return.notification =
- bt_notification_inactivity_create(src_empty_cc_prio_map);
+ bt_notification_inactivity_create(graph,
+ src_empty_cc_prio_map);
assert(next_return.notification);
break;
case SEQ_STREAM1_BEGIN:
next_return.notification =
- bt_notification_stream_begin_create(src_stream1);
+ bt_notification_stream_begin_create(graph, src_stream1);
assert(next_return.notification);
break;
case SEQ_STREAM2_BEGIN:
next_return.notification =
- bt_notification_stream_begin_create(src_stream2);
+ bt_notification_stream_begin_create(graph, src_stream2);
assert(next_return.notification);
break;
case SEQ_STREAM1_END:
next_return.notification =
- bt_notification_stream_end_create(src_stream1);
+ bt_notification_stream_end_create(graph, src_stream1);
assert(next_return.notification);
break;
case SEQ_STREAM2_END:
next_return.notification =
- bt_notification_stream_end_create(src_stream2);
+ bt_notification_stream_end_create(graph, src_stream2);
assert(next_return.notification);
break;
case SEQ_STREAM1_PACKET1_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(src_stream1_packet1);
+ bt_notification_packet_begin_create(graph,
+ src_stream1_packet1);
assert(next_return.notification);
break;
case SEQ_STREAM1_PACKET2_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(src_stream1_packet2);
+ bt_notification_packet_begin_create(graph,
+ src_stream1_packet2);
assert(next_return.notification);
break;
case SEQ_STREAM2_PACKET1_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(src_stream2_packet1);
+ bt_notification_packet_begin_create(graph,
+ src_stream2_packet1);
assert(next_return.notification);
break;
case SEQ_STREAM2_PACKET2_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(src_stream2_packet2);
+ bt_notification_packet_begin_create(graph,
+ src_stream2_packet2);
assert(next_return.notification);
break;
case SEQ_STREAM1_PACKET1_END:
next_return.notification =
- bt_notification_packet_end_create(src_stream1_packet1);
+ bt_notification_packet_end_create(graph,
+ src_stream1_packet1);
assert(next_return.notification);
break;
case SEQ_STREAM1_PACKET2_END:
next_return.notification =
- bt_notification_packet_end_create(src_stream1_packet2);
+ bt_notification_packet_end_create(graph,
+ src_stream1_packet2);
assert(next_return.notification);
break;
case SEQ_STREAM2_PACKET1_END:
next_return.notification =
- bt_notification_packet_end_create(src_stream2_packet1);
+ bt_notification_packet_end_create(graph,
+ src_stream2_packet1);
assert(next_return.notification);
break;
case SEQ_STREAM2_PACKET2_END:
next_return.notification =
- bt_notification_packet_end_create(src_stream2_packet2);
+ bt_notification_packet_end_create(graph,
+ src_stream2_packet2);
assert(next_return.notification);
break;
case SEQ_EVENT_STREAM1_PACKET1:
if (event_packet) {
next_return.notification =
- bt_notification_event_create(src_event_class,
- event_packet,
- src_empty_cc_prio_map);
+ bt_notification_event_create(graph, src_event_class,
+ event_packet, src_empty_cc_prio_map);
assert(next_return.notification);
}
struct bt_component *sink_comp;
struct bt_port *upstream_port;
struct bt_port *downstream_port;
- struct bt_graph *graph;
enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
clear_test_events();
current_test = test;
diag("test: %s", name);
+ assert(!graph);
graph = bt_graph_create();
assert(graph);
create_source_sink(graph, &src_comp, &sink_comp);
bt_put(src_comp);
bt_put(sink_comp);
- bt_put(graph);
+ BT_PUT(graph);
}
static
enum bt_notification_iterator_status iter_status =
BT_NOTIFICATION_ITERATOR_STATUS_OK;
struct bt_port *upstream_port;
- struct bt_graph *graph;
clear_test_events();
current_test = TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR;
diag("test: output port notification iterator");
+ assert(!graph);
graph = bt_graph_create();
assert(graph);
create_source_sink(graph, &src_comp, NULL);
"the produced sequence of test events is the expected one");
bt_put(src_comp);
- bt_put(graph);
+ BT_PUT(graph);
bt_put(notif_iter);
}
struct bt_component *src_comp;
struct bt_notification_iterator *notif_iter;
struct bt_port *upstream_port;
- struct bt_graph *graph;
clear_test_events();
current_test = TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR;
diag("test: cannot consume graph with existing output port notification iterator");
+ assert(!graph);
graph = bt_graph_create();
assert(graph);
create_source_sink(graph, &src_comp, NULL);
"bt_graph_run() returns BT_GRAPH_STATUS_CANNOT_CONSUME when there's an output port notification iterator");
bt_put(src_comp);
- bt_put(graph);
+ BT_PUT(graph);
bt_put(notif_iter);
}
struct event event = {
.type = COMP_ACCEPT_PORT_CONNECTION,
.data.comp_accept_port_connection = {
- .comp = bt_component_from_private(private_component),
- .self_port = bt_port_from_private(self_private_port),
+ .comp = bt_component_borrow_from_private(private_component),
+ .self_port = bt_port_borrow_from_private(self_private_port),
.other_port = other_port,
},
};
- bt_put(event.data.comp_accept_port_connection.comp);
- bt_put(event.data.comp_accept_port_connection.self_port);
append_event(&event);
return BT_COMPONENT_STATUS_OK;
}
struct event event = {
.type = COMP_PORT_CONNECTED,
.data.comp_port_connected = {
- .comp = bt_component_from_private(private_component),
- .self_port = bt_port_from_private(self_private_port),
+ .comp = bt_component_borrow_from_private(private_component),
+ .self_port = bt_port_borrow_from_private(self_private_port),
.other_port = other_port,
},
};
- bt_put(event.data.comp_port_connected.comp);
- bt_put(event.data.comp_port_connected.self_port);
append_event(&event);
switch (current_test) {
struct event event = {
.type = COMP_PORT_DISCONNECTED,
.data.comp_port_disconnected = {
- .comp = bt_component_from_private(private_component),
- .port = bt_port_from_private(private_port),
+ .comp = bt_component_borrow_from_private(private_component),
+ .port = bt_port_borrow_from_private(private_port),
},
};
- bt_put(event.data.comp_port_disconnected.comp);
- bt_put(event.data.comp_port_disconnected.port);
append_event(&event);
switch (current_test) {
struct event event = {
.type = COMP_PORT_CONNECTED,
.data.comp_port_connected = {
- .comp = bt_component_from_private(private_component),
- .self_port = bt_port_from_private(self_private_port),
+ .comp = bt_component_borrow_from_private(private_component),
+ .self_port = bt_port_borrow_from_private(self_private_port),
.other_port = other_port,
},
};
- bt_put(event.data.comp_port_connected.comp);
- bt_put(event.data.comp_port_connected.self_port);
append_event(&event);
}
struct event event = {
.type = COMP_PORT_DISCONNECTED,
.data.comp_port_disconnected = {
- .comp = bt_component_from_private(private_component),
- .port = bt_port_from_private(private_port),
+ .comp = bt_component_borrow_from_private(private_component),
+ .port = bt_port_borrow_from_private(private_port),
},
};
- bt_put(event.data.comp_port_disconnected.comp);
- bt_put(event.data.comp_port_disconnected.port);
append_event(&event);
}
static bool debug = false;
static enum test current_test;
static GArray *test_events;
+static struct bt_graph *graph;
static struct bt_clock_class_priority_map *src_cc_prio_map;
static struct bt_clock_class_priority_map *src_empty_cc_prio_map;
static struct bt_clock_class *src_clock_class;
{
struct src_iter_user_data *user_data =
g_new0(struct src_iter_user_data, 1);
- struct bt_port *port = bt_port_from_private(private_port);
+ struct bt_port *port = bt_port_borrow_from_private(private_port);
const char *port_name;
int ret;
port_name = bt_port_get_name(port);
assert(port_name);
user_data->iter_index = port_name[3] - '0';
- bt_put(port);
switch (user_data->iter_index) {
case 0:
struct bt_clock_value *clock_value;
struct bt_field *field;
- notif = bt_notification_event_create(src_event_class,
+ notif = bt_notification_event_create(graph, src_event_class,
packet, cc_prio_map);
assert(notif);
event = bt_notification_event_borrow_event(notif);
break;
case SEQ_PACKET_BEGIN:
next_return.notification =
- bt_notification_packet_begin_create(user_data->packet);
+ bt_notification_packet_begin_create(graph,
+ user_data->packet);
assert(next_return.notification);
break;
case SEQ_PACKET_END:
next_return.notification =
- bt_notification_packet_end_create(user_data->packet);
+ bt_notification_packet_end_create(graph,
+ user_data->packet);
assert(next_return.notification);
break;
case SEQ_STREAM_BEGIN:
stream = bt_packet_get_stream(user_data->packet);
next_return.notification =
- bt_notification_stream_begin_create(stream);
+ bt_notification_stream_begin_create(graph, stream);
assert(next_return.notification);
bt_put(stream);
break;
case SEQ_STREAM_END:
stream = bt_packet_get_stream(user_data->packet);
next_return.notification =
- bt_notification_stream_end_create(stream);
+ bt_notification_stream_end_create(graph, stream);
assert(next_return.notification);
bt_put(stream);
break;
stream = bt_packet_get_stream(user_data->packet);
next_return.notification =
bt_notification_stream_begin_create(
- stream);
+ graph, stream);
bt_put(stream);
assert(next_return.notification);
} else if (user_data->at == 1) {
next_return.notification =
bt_notification_packet_begin_create(
- user_data->packet);
+ graph, user_data->packet);
assert(next_return.notification);
} else if (user_data->at < 7) {
next_return.notification =
} else if (user_data->at == 7) {
next_return.notification =
bt_notification_packet_end_create(
- user_data->packet);
+ graph, user_data->packet);
assert(next_return.notification);
} else if (user_data->at == 8) {
stream = bt_packet_get_stream(user_data->packet);
next_return.notification =
bt_notification_stream_end_create(
- stream);
+ graph, stream);
bt_put(stream);
assert(next_return.notification);
} else {
struct bt_component *sink_comp;
struct bt_port *upstream_port;
struct bt_port *downstream_port;
- struct bt_graph *graph;
int64_t i;
int64_t count;
enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
clear_test_events();
current_test = test;
diag("test: %s", name);
+ assert(!graph);
graph = bt_graph_create();
assert(graph);
create_source_muxer_sink(graph, &src_comp, &muxer_comp, &sink_comp);
bt_put(src_comp);
bt_put(muxer_comp);
bt_put(sink_comp);
- bt_put(graph);
+ BT_PUT(graph);
}
static
struct bt_component *sink_comp;
struct bt_port *upstream_port;
struct bt_port *downstream_port;
- struct bt_graph *graph;
int64_t i;
int64_t count;
int ret;
clear_test_events();
current_test = TEST_SINGLE_END_THEN_MULTIPLE_FULL;
diag("test: single end then multiple full");
+ assert(!graph);
graph = bt_graph_create();
assert(graph);
create_source_muxer_sink(graph, &src_comp, &muxer_comp, &sink_comp);
bt_put(src_comp);
bt_put(muxer_comp);
bt_put(sink_comp);
- bt_put(graph);
+ BT_PUT(graph);
}
static
struct bt_component *sink_comp;
struct bt_port *upstream_port;
struct bt_port *downstream_port;
- struct bt_graph *graph;
int64_t i;
int64_t count;
int ret;
clear_test_events();
current_test = TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL;
diag("test: single again then end then multiple full");
+ assert(!graph);
graph = bt_graph_create();
assert(graph);
create_source_muxer_sink(graph, &src_comp, &muxer_comp, &sink_comp);
bt_put(src_comp);
bt_put(muxer_comp);
bt_put(sink_comp);
- bt_put(graph);
+ BT_PUT(graph);
}
#define DEBUG_ENV_VAR "TEST_UTILS_MUXER_DEBUG"