bin: compile lttng-sessiond as C++
[lttng-tools.git] / src / common / index-allocator.h
CommitLineData
246611b0
FD
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
7966af57
SM
13#ifdef __cplusplus
14extern "C" {
15#endif
16
246611b0
FD
17struct lttng_index_allocator;
18
19enum lttng_index_allocator_status {
20 LTTNG_INDEX_ALLOCATOR_STATUS_OK,
21 LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY,
22 LTTNG_INDEX_ALLOCATOR_STATUS_ERROR,
23};
24
25/*
26 * Create an index allocator of `index_count` slots.
27 */
28struct lttng_index_allocator *lttng_index_allocator_create(
29 uint64_t index_count);
30
31/*
32 * Get the number of indexes currently in use.
33 */
34uint64_t lttng_index_allocator_get_index_count(
35 struct lttng_index_allocator *allocator);
36
37/*
38 * Allocate (i.e. reserve) a slot.
39 */
40enum 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 */
48enum lttng_index_allocator_status lttng_index_allocator_release(
49 struct lttng_index_allocator *allocator, uint64_t index);
50
51/*
52 * Destroy an index allocator.
53 */
54void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
55
7966af57
SM
56#ifdef __cplusplus
57}
58#endif
59
246611b0 60#endif /* _COMMON_INDEX_ALLOCATOR_H */
This page took 0.026971 seconds and 4 git commands to generate.