vscode: Add configurations to run the executables under the debugger
[lttng-tools.git] / src / common / index-allocator.hpp
1 /*
2 * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef _COMMON_INDEX_ALLOCATOR_H
9 #define _COMMON_INDEX_ALLOCATOR_H
10
11 #include <inttypes.h>
12 #include <lttng/lttng-export.h>
13
14 struct lttng_index_allocator;
15
16 enum lttng_index_allocator_status {
17 LTTNG_INDEX_ALLOCATOR_STATUS_OK,
18 LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY,
19 LTTNG_INDEX_ALLOCATOR_STATUS_ERROR,
20 };
21
22 /*
23 * Create an index allocator of `index_count` slots.
24 */
25 extern "C" LTTNG_EXPORT
26 struct lttng_index_allocator *lttng_index_allocator_create(
27 uint64_t index_count);
28
29 /*
30 * Get the number of indexes currently in use.
31 */
32 extern "C" LTTNG_EXPORT
33 uint64_t lttng_index_allocator_get_index_count(
34 struct lttng_index_allocator *allocator);
35
36 /*
37 * Allocate (i.e. reserve) a slot.
38 */
39 extern "C" LTTNG_EXPORT
40 enum lttng_index_allocator_status lttng_index_allocator_alloc(
41 struct lttng_index_allocator *allocator,
42 uint64_t *index);
43
44 /*
45 * Release a slot by index. The slot will be re-used by the index allocator
46 * in future 'alloc' calls.
47 */
48 extern "C" LTTNG_EXPORT
49 enum lttng_index_allocator_status lttng_index_allocator_release(
50 struct lttng_index_allocator *allocator, uint64_t index);
51
52 /*
53 * Destroy an index allocator.
54 */
55 extern "C" LTTNG_EXPORT
56 void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
57
58 #endif /* _COMMON_INDEX_ALLOCATOR_H */
This page took 0.031099 seconds and 4 git commands to generate.