lib: compile liblttng-ctl as C++
[lttng-tools.git] / src / common / index-allocator.h
... / ...
CommitLineData
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#ifdef __cplusplus
15extern "C" {
16#endif
17
18struct lttng_index_allocator;
19
20enum lttng_index_allocator_status {
21 LTTNG_INDEX_ALLOCATOR_STATUS_OK,
22 LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY,
23 LTTNG_INDEX_ALLOCATOR_STATUS_ERROR,
24};
25
26/*
27 * Create an index allocator of `index_count` slots.
28 */
29LTTNG_EXPORT struct lttng_index_allocator *lttng_index_allocator_create(
30 uint64_t index_count);
31
32/*
33 * Get the number of indexes currently in use.
34 */
35LTTNG_EXPORT uint64_t lttng_index_allocator_get_index_count(
36 struct lttng_index_allocator *allocator);
37
38/*
39 * Allocate (i.e. reserve) a slot.
40 */
41LTTNG_EXPORT enum lttng_index_allocator_status lttng_index_allocator_alloc(
42 struct lttng_index_allocator *allocator,
43 uint64_t *index);
44
45/*
46 * Release a slot by index. The slot will be re-used by the index allocator
47 * in future 'alloc' calls.
48 */
49LTTNG_EXPORT 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 */
55LTTNG_EXPORT void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
56
57#ifdef __cplusplus
58}
59#endif
60
61#endif /* _COMMON_INDEX_ALLOCATOR_H */
This page took 0.024931 seconds and 4 git commands to generate.