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