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