Tests: Fix: Use '.logfile' instead of '.log' for test app output
[lttng-tools.git] / src / common / index-allocator.hpp
... / ...
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 <lttng/lttng-export.h>
12
13#include <inttypes.h>
14
15struct lttng_index_allocator;
16
17enum 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 */
26extern "C" LTTNG_EXPORT struct lttng_index_allocator *
27lttng_index_allocator_create(uint64_t index_count);
28
29/*
30 * Get the number of indexes currently in use.
31 */
32extern "C" LTTNG_EXPORT uint64_t
33lttng_index_allocator_get_index_count(struct lttng_index_allocator *allocator);
34
35/*
36 * Allocate (i.e. reserve) a slot.
37 */
38extern "C" LTTNG_EXPORT enum lttng_index_allocator_status
39lttng_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 */
45extern "C" LTTNG_EXPORT enum lttng_index_allocator_status
46lttng_index_allocator_release(struct lttng_index_allocator *allocator, uint64_t index);
47
48/*
49 * Destroy an index allocator.
50 */
51extern "C" LTTNG_EXPORT void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
52
53#endif /* _COMMON_INDEX_ALLOCATOR_H */
This page took 0.023807 seconds and 5 git commands to generate.