| 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 | |
| 13 | struct lttng_index_allocator; |
| 14 | |
| 15 | enum 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 | struct lttng_index_allocator *lttng_index_allocator_create( |
| 22 | uint64_t index_count); |
| 23 | |
| 24 | uint64_t lttng_index_allocator_get_index_count( |
| 25 | struct lttng_index_allocator *allocator); |
| 26 | |
| 27 | enum lttng_index_allocator_status lttng_index_allocator_alloc( |
| 28 | struct lttng_index_allocator *allocator, |
| 29 | uint64_t *index); |
| 30 | |
| 31 | enum lttng_index_allocator_status lttng_index_allocator_release( |
| 32 | struct lttng_index_allocator *allocator, uint64_t index); |
| 33 | |
| 34 | void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator); |
| 35 | |
| 36 | #endif /* _COMMON_INDEX_ALLOCATOR_H */ |