Commit | Line | Data |
---|---|---|
784cdc68 | 1 | /* |
0235b0db MJ |
2 | * SPDX-License-Identifier: MIT |
3 | * | |
e2f7325d | 4 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
784cdc68 | 5 | * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
784cdc68 JG |
6 | */ |
7 | ||
0235b0db MJ |
8 | #ifndef BABELTRACE_GRAPH_CONNECTION_INTERNAL_H |
9 | #define BABELTRACE_GRAPH_CONNECTION_INTERNAL_H | |
10 | ||
43c59509 | 11 | #include <babeltrace2/graph/connection.h> |
578e048b MJ |
12 | #include "lib/object.h" |
13 | #include "common/assert.h" | |
91d81473 | 14 | #include "common/macros.h" |
c42ea0af | 15 | #include <stdbool.h> |
784cdc68 | 16 | |
5155b005 | 17 | #include "iterator.h" |
578e048b | 18 | |
784cdc68 JG |
19 | struct bt_graph; |
20 | ||
21 | struct bt_connection { | |
22 | /* | |
23 | * The graph is a connection's parent and the connection is the parent | |
24 | * of all iterators it has created. | |
25 | */ | |
26 | struct bt_object base; | |
27 | /* | |
28 | * Weak references are held to both ports. Their existence is guaranteed | |
29 | * by the existence of the graph and thus, of their respective | |
30 | * components. | |
31 | */ | |
32 | /* Downstream port. */ | |
72b913fb | 33 | struct bt_port *downstream_port; |
784cdc68 | 34 | /* Upstream port. */ |
72b913fb | 35 | struct bt_port *upstream_port; |
bd14d768 PP |
36 | |
37 | /* | |
d6e69534 | 38 | * Weak references to all the message iterators that were |
bd14d768 PP |
39 | * created on this connection. |
40 | */ | |
41 | GPtrArray *iterators; | |
bf55043c | 42 | |
85031ceb | 43 | bool notified_upstream_port_connected; |
85031ceb | 44 | bool notified_downstream_port_connected; |
85031ceb | 45 | bool notified_graph_ports_connected; |
784cdc68 JG |
46 | }; |
47 | ||
784cdc68 | 48 | struct bt_connection *bt_connection_create(struct bt_graph *graph, |
72b913fb PP |
49 | struct bt_port *upstream_port, |
50 | struct bt_port *downstream_port); | |
51 | ||
c42ea0af | 52 | void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph); |
784cdc68 | 53 | |
bd14d768 | 54 | void bt_connection_remove_iterator(struct bt_connection *conn, |
9a2c8b8e | 55 | struct bt_message_iterator *iterator); |
bd14d768 | 56 | |
c28d097c PP |
57 | static inline |
58 | struct bt_graph *bt_connection_borrow_graph(struct bt_connection *conn) | |
59 | { | |
98b15851 | 60 | BT_ASSERT_DBG(conn); |
c28d097c PP |
61 | return (void *) conn->base.parent; |
62 | } | |
63 | ||
6ac74c0c | 64 | #endif /* BABELTRACE_GRAPH_CONNECTION_INTERNAL_H */ |