Commit | Line | Data |
---|---|---|
1545fd17 JG |
1 | /* |
2 | * Copyright (C) 2019 - Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU Lesser General Public License, version 2.1 only, | |
6 | * as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | |
11 | * for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU Lesser General Public License | |
14 | * along with this program; if not, write to the Free Software Foundation, | |
15 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
16 | */ | |
17 | ||
18 | #ifndef LTTNG_TRACE_CHUNK_REGISTRY_H | |
19 | #define LTTNG_TRACE_CHUNK_REGISTRY_H | |
20 | ||
21 | #include <stddef.h> | |
22 | #include <stdint.h> | |
23 | #include <stdbool.h> | |
24 | #include <common/macros.h> | |
25 | #include <common/trace-chunk.h> | |
26 | ||
27 | struct lttng_trace_chunk_registry; | |
28 | ||
29 | /* | |
30 | * Create an lttng_trace_chunk registry. | |
31 | * | |
32 | * A trace chunk registry maintains an association between a | |
33 | * (session_id, chunk_id) tuple and a trace chunk object. The chunk_id can | |
34 | * be "unset" in the case of an anonymous trace chunk. | |
35 | * | |
36 | * Note that a trace chunk registry holds no ownership of its trace | |
37 | * chunks. Trace chunks are unpublished when their last reference is released. | |
38 | * See the documentation of lttng_trace_chunk. | |
39 | * | |
40 | * Returns a trace chunk registry on success, NULL on error. | |
41 | * | |
42 | * Note that a trace chunk registry may only be accessed by an RCU thread. | |
43 | */ | |
44 | LTTNG_HIDDEN | |
45 | struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void); | |
46 | ||
47 | /* | |
48 | * Destroy an lttng trace chunk registry. The registry must be emptied | |
49 | * (i.e. all references to the trace chunks it contains must be released) before | |
50 | * it is destroyed. | |
51 | */ | |
52 | LTTNG_HIDDEN | |
53 | void lttng_trace_chunk_registry_destroy( | |
54 | struct lttng_trace_chunk_registry *registry); | |
55 | ||
56 | /* | |
57 | * Publish a trace chunk for a given session id. | |
58 | * A reference is acquired on behalf of the caller. | |
59 | * | |
60 | * The trace chunk that is returned is the published version of the trace | |
61 | * chunk. The chunk provided should be discarded on success and it's | |
62 | * published version used in its place. | |
63 | * | |
64 | * See the documentation of lttng_trace_chunk for more information on | |
65 | * the usage of the various parameters. | |
66 | * | |
67 | * Returns an lttng_trace_chunk on success, NULL on error. | |
68 | */ | |
69 | LTTNG_HIDDEN | |
70 | struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk( | |
71 | struct lttng_trace_chunk_registry *registry, | |
72 | uint64_t session_id, struct lttng_trace_chunk *chunk); | |
73 | ||
74 | /* | |
75 | * Look-up a trace chunk by session_id and chunk_id. | |
76 | * A reference is acquired on behalf of the caller. | |
77 | * | |
78 | * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist. | |
79 | */ | |
80 | LTTNG_HIDDEN | |
81 | struct lttng_trace_chunk * | |
82 | lttng_trace_chunk_registry_find_chunk( | |
83 | const struct lttng_trace_chunk_registry *registry, | |
84 | uint64_t session_id, uint64_t chunk_id); | |
85 | ||
86 | /* | |
87 | * Look-up an anonymous trace chunk by session_id. | |
88 | * A reference is acquired on behalf of the caller. | |
89 | * | |
90 | * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist. | |
91 | */ | |
92 | LTTNG_HIDDEN | |
93 | struct lttng_trace_chunk * | |
94 | lttng_trace_chunk_registry_find_anonymous_chunk( | |
95 | const struct lttng_trace_chunk_registry *registry, | |
96 | uint64_t session_id); | |
97 | ||
98 | #endif /* LTTNG_TRACE_CHUNK_REGISTRY_H */ |