vitastor/allocator.h

22 lines
422 B
C
Raw Normal View History

// Copyright (c) Vitaliy Filippov, 2019+
// License: VNPL-1.0 (see README.md for details)
2019-10-28 01:22:01 +03:00
#pragma once
#include <stdint.h>
// Hierarchical bitmap allocator
2019-11-27 00:50:57 +03:00
class allocator
2019-10-28 01:22:01 +03:00
{
uint64_t size;
uint64_t free;
2019-10-28 01:22:01 +03:00
uint64_t last_one_mask;
2019-11-27 00:50:57 +03:00
uint64_t *mask;
public:
allocator(uint64_t blocks);
~allocator();
void set(uint64_t addr, bool value);
uint64_t find_free();
uint64_t get_free_count();
2019-10-28 01:22:01 +03:00
};