f61e560808486c37b1640d3ed04bce0a6cf48555
[lttng-tools.git] / src / common / trace-chunk-registry.h
1 /*
2 * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_TRACE_CHUNK_REGISTRY_H
9 #define LTTNG_TRACE_CHUNK_REGISTRY_H
10
11 #include <stddef.h>
12 #include <stdint.h>
13 #include <stdbool.h>
14 #include <common/macros.h>
15 #include <common/trace-chunk.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 struct lttng_trace_chunk_registry;
22
23 /*
24 * Create an lttng_trace_chunk registry.
25 *
26 * A trace chunk registry maintains an association between a
27 * (session_id, chunk_id) tuple and a trace chunk object. The chunk_id can
28 * be "unset" in the case of an anonymous trace chunk.
29 *
30 * Note that a trace chunk registry holds no ownership of its trace
31 * chunks. Trace chunks are unpublished when their last reference is released.
32 * See the documentation of lttng_trace_chunk.
33 *
34 * Returns a trace chunk registry on success, NULL on error.
35 *
36 * Note that a trace chunk registry may only be accessed by an RCU thread.
37 */
38 struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void);
39
40 /*
41 * Destroy an lttng trace chunk registry. The registry must be emptied
42 * (i.e. all references to the trace chunks it contains must be released) before
43 * it is destroyed.
44 */
45 void lttng_trace_chunk_registry_destroy(
46 struct lttng_trace_chunk_registry *registry);
47
48 /*
49 * Publish a trace chunk for a given session id.
50 * A reference is acquired on behalf of the caller.
51 *
52 * The trace chunk that is returned is the published version of the trace
53 * chunk. The chunk provided should be discarded on success and it's
54 * published version used in its place.
55 *
56 * See the documentation of lttng_trace_chunk for more information on
57 * the usage of the various parameters.
58 *
59 * Returns an lttng_trace_chunk on success, NULL on error.
60 */
61 struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk(
62 struct lttng_trace_chunk_registry *registry,
63 uint64_t session_id, struct lttng_trace_chunk *chunk);
64
65 /*
66 * Look-up a trace chunk by session_id and chunk_id.
67 * A reference is acquired on behalf of the caller.
68 *
69 * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
70 */
71 struct lttng_trace_chunk *
72 lttng_trace_chunk_registry_find_chunk(
73 const struct lttng_trace_chunk_registry *registry,
74 uint64_t session_id, uint64_t chunk_id);
75
76 /*
77 * Query the existence of a trace chunk by session_id and chunk_id.
78 *
79 * Returns 0 on success, a negative value on error.
80 */
81 int lttng_trace_chunk_registry_chunk_exists(
82 const struct lttng_trace_chunk_registry *registry,
83 uint64_t session_id, uint64_t chunk_id, bool *chunk_exists);
84
85 /*
86 * Look-up an anonymous trace chunk by session_id.
87 * A reference is acquired on behalf of the caller.
88 *
89 * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
90 */
91 struct lttng_trace_chunk *
92 lttng_trace_chunk_registry_find_anonymous_chunk(
93 const struct lttng_trace_chunk_registry *registry,
94 uint64_t session_id);
95
96 unsigned int lttng_trace_chunk_registry_put_each_chunk(
97 const struct lttng_trace_chunk_registry *registry);
98
99 #ifdef __cplusplus
100 }
101 #endif
102
103 #endif /* LTTNG_TRACE_CHUNK_REGISTRY_H */
This page took 0.031691 seconds and 4 git commands to generate.