YAMI4 Core Library 2.0.0
Messaging Solution for Distributed Systems
Loading...
Searching...
No Matches
allocator.h
1// Copyright Maciej Sobczak 2008-2022.
2// This file is part of YAMI4.
3// See the package-level LICENSE.txt file.
4
5#ifndef YAMICORE_ALLOCATOR_H_INCLUDED
6#define YAMICORE_ALLOCATOR_H_INCLUDED
7
8#include "dll.h"
9
10#include <cstddef>
11
12namespace yami
13{
14
15namespace core
16{
17
19class DLL allocator
20{
21public:
22 virtual void * allocate(std::size_t requested_size) = 0;
23
24 virtual void deallocate(const void * p) = 0;
25};
26
28class DLL standard_allocator : public allocator
29{
30public:
31 virtual void * allocate(std::size_t requested_size);
32
33 virtual void deallocate(const void * p);
34};
35
46{
47public:
49
50 void set_working_area(void * buf, std::size_t size);
51
52 virtual void * allocate(std::size_t requested_size);
53
54 virtual void deallocate(const void * p);
55
56 void get_free_size(std::size_t & biggest, std::size_t & all) const;
57
58private:
60 void operator=(const non_locked_allocator &);
61
62 void * base_;
63 std::size_t size_;
64
65 void * first_free_segment_;
66};
67
68} // namespace core
69
70} // namespace yami
71
72#endif // YAMICORE_ALLOCATOR_H_INCLUDED
Common interface for the custom memory allocator.
Definition: allocator.h:20
Non-locking (thread-unsafe) block-based allocator.
Definition: allocator.h:46
Standard (malloc/free), default allocator.
Definition: allocator.h:29
Namespace devoted for everything related to YAMI4.
Definition: agent.h:14