2 * Copyright (C) 2019 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
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.
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
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
18 #ifndef LTTNG_TRACE_CHUNK_REGISTRY_H
19 #define LTTNG_TRACE_CHUNK_REGISTRY_H
24 #include <common/macros.h>
25 #include <common/trace-chunk.h>
27 struct lttng_trace_chunk_registry
;
30 * Create an lttng_trace_chunk registry.
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.
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.
40 * Returns a trace chunk registry on success, NULL on error.
42 * Note that a trace chunk registry may only be accessed by an RCU thread.
45 struct lttng_trace_chunk_registry
*lttng_trace_chunk_registry_create(void);
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
53 void lttng_trace_chunk_registry_destroy(
54 struct lttng_trace_chunk_registry
*registry
);
57 * Publish a trace chunk for a given session id.
58 * A reference is acquired on behalf of the caller.
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.
64 * See the documentation of lttng_trace_chunk for more information on
65 * the usage of the various parameters.
67 * Returns an lttng_trace_chunk on success, NULL on error.
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
);
75 * Look-up a trace chunk by session_id and chunk_id.
76 * A reference is acquired on behalf of the caller.
78 * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
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
);
87 * Look-up an anonymous trace chunk by session_id.
88 * A reference is acquired on behalf of the caller.
90 * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
93 struct lttng_trace_chunk
*
94 lttng_trace_chunk_registry_find_anonymous_chunk(
95 const struct lttng_trace_chunk_registry
*registry
,
98 #endif /* LTTNG_TRACE_CHUNK_REGISTRY_H */