Change-Id: I508ac4791749240e511ef832a97e92878dd68df2
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#ifndef _COMMON_INDEX_ALLOCATOR_H
#define _COMMON_INDEX_ALLOCATOR_H
#ifndef _COMMON_INDEX_ALLOCATOR_H
#define _COMMON_INDEX_ALLOCATOR_H
+#include <common/macros.h>
#include <inttypes.h>
struct lttng_index_allocator;
#include <inttypes.h>
struct lttng_index_allocator;
/*
* Create an index allocator of `index_count` slots.
*/
/*
* Create an index allocator of `index_count` slots.
*/
struct lttng_index_allocator *lttng_index_allocator_create(
uint64_t index_count);
/*
* Get the number of indexes currently in use.
*/
struct lttng_index_allocator *lttng_index_allocator_create(
uint64_t index_count);
/*
* Get the number of indexes currently in use.
*/
uint64_t lttng_index_allocator_get_index_count(
struct lttng_index_allocator *allocator);
/*
* Allocate (i.e. reserve) a slot.
*/
uint64_t lttng_index_allocator_get_index_count(
struct lttng_index_allocator *allocator);
/*
* Allocate (i.e. reserve) a slot.
*/
enum lttng_index_allocator_status lttng_index_allocator_alloc(
struct lttng_index_allocator *allocator,
uint64_t *index);
enum lttng_index_allocator_status lttng_index_allocator_alloc(
struct lttng_index_allocator *allocator,
uint64_t *index);
* Release a slot by index. The slot will be re-used by the index allocator
* in future 'alloc' calls.
*/
* Release a slot by index. The slot will be re-used by the index allocator
* in future 'alloc' calls.
*/
enum lttng_index_allocator_status lttng_index_allocator_release(
struct lttng_index_allocator *allocator, uint64_t index);
/*
* Destroy an index allocator.
*/
enum lttng_index_allocator_status lttng_index_allocator_release(
struct lttng_index_allocator *allocator, uint64_t index);
/*
* Destroy an index allocator.
*/
void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
#endif /* _COMMON_INDEX_ALLOCATOR_H */
void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
#endif /* _COMMON_INDEX_ALLOCATOR_H */