tests: Use `--no-wait` when destroying sessions in relayd-grouping
[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 <lttng/lttng-export.h>
12
13 #include <inttypes.h>
14
15 struct lttng_index_allocator;
16
17 enum lttng_index_allocator_status {
18 LTTNG_INDEX_ALLOCATOR_STATUS_OK,
19 LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY,
20 LTTNG_INDEX_ALLOCATOR_STATUS_ERROR,
21 };
22
23 /*
24 * Create an index allocator of `index_count` slots.
25 */
26 extern "C" LTTNG_EXPORT struct lttng_index_allocator *
27 lttng_index_allocator_create(uint64_t index_count);
28
29 /*
30 * Get the number of indexes currently in use.
31 */
32 extern "C" LTTNG_EXPORT uint64_t
33 lttng_index_allocator_get_index_count(struct lttng_index_allocator *allocator);
34
35 /*
36 * Allocate (i.e. reserve) a slot.
37 */
38 extern "C" LTTNG_EXPORT enum lttng_index_allocator_status
39 lttng_index_allocator_alloc(struct lttng_index_allocator *allocator, uint64_t *index);
40
41 /*
42 * Release a slot by index. The slot will be re-used by the index allocator
43 * in future 'alloc' calls.
44 */
45 extern "C" LTTNG_EXPORT enum lttng_index_allocator_status
46 lttng_index_allocator_release(struct lttng_index_allocator *allocator, uint64_t index);
47
48 /*
49 * Destroy an index allocator.
50 */
51 extern "C" LTTNG_EXPORT void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
52
53 #endif /* _COMMON_INDEX_ALLOCATOR_H */
This page took 0.032738 seconds and 4 git commands to generate.