]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/cpp/src/plasma/plasma_allocator.h
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / cpp / src / plasma / plasma_allocator.h
CommitLineData
1d09f67e
TL
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#pragma once
19
20#include <cstddef>
21#include <cstdint>
22
23namespace plasma {
24
25class PlasmaAllocator {
26 public:
27 /// Allocates size bytes and returns a pointer to the allocated memory. The
28 /// memory address will be a multiple of alignment, which must be a power of two.
29 ///
30 /// \param alignment Memory alignment.
31 /// \param bytes Number of bytes.
32 /// \return Pointer to allocated memory.
33 static void* Memalign(size_t alignment, size_t bytes);
34
35 /// Frees the memory space pointed to by mem, which must have been returned by
36 /// a previous call to Memalign()
37 ///
38 /// \param mem Pointer to memory to free.
39 /// \param bytes Number of bytes to be freed.
40 static void Free(void* mem, size_t bytes);
41
42 /// Sets the memory footprint limit for Plasma.
43 ///
44 /// \param bytes Plasma memory footprint limit in bytes.
45 static void SetFootprintLimit(size_t bytes);
46
47 /// Get the memory footprint limit for Plasma.
48 ///
49 /// \return Plasma memory footprint limit in bytes.
50 static int64_t GetFootprintLimit();
51
52 /// Get the number of bytes allocated by Plasma so far.
53 /// \return Number of bytes allocated by Plasma so far.
54 static int64_t Allocated();
55
56 private:
57 static int64_t allocated_;
58 static int64_t footprint_limit_;
59};
60
61} // namespace plasma