Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
RPageAllocator.hxx
Go to the documentation of this file.
1/// \file ROOT/RPageAllocator.hxx
2/// \author Jakob Blomer <jblomer@cern.ch>
3/// \date 2019-06-25
4
5/*************************************************************************
6 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT_RPageAllocator
14#define ROOT_RPageAllocator
15
16#include <ROOT/RNTupleTypes.hxx>
17#include <ROOT/RPage.hxx>
18
19#include <cstddef>
20#include <functional>
21
22namespace ROOT {
23namespace Internal {
24
25// clang-format off
26/**
27\class ROOT::Internal::RPageAllocator
28\ingroup NTuple
29\brief Abstract interface to allocate and release pages
30
31The page allocator acquires and releases memory for pages. It does not load the page data, the returned pages
32are empty but guaranteed to have enough contiguous space for the given number of elements.
33The page allocator must be thread-safe.
34*/
35// clang-format on
37 friend class RPage;
38
39protected:
40 /// Releases the memory pointed to by page and resets the page's information. Note that the memory of the
41 /// zero page must not be deleted. Called by the RPage destructor.
42 virtual void DeletePage(RPage &page) = 0;
43
44public:
45 virtual ~RPageAllocator() = default;
46
47 /// Reserves memory large enough to hold nElements of the given size. The page is immediately tagged with
48 /// a column id. Returns a default constructed page on out-of-memory condition.
49 virtual RPage NewPage(std::size_t elementSize, std::size_t nElements) = 0;
50};
51
52// clang-format off
53/**
54\class ROOT::Internal::RPageAllocatorHeap
55\ingroup NTuple
56\brief Uses standard C++ memory allocation for the column data pages
57*/
58// clang-format on
60protected:
61 void DeletePage(RPage &page) final;
62
63public:
64 RPage NewPage(std::size_t elementSize, std::size_t nElements) final;
65};
66
67} // namespace Internal
68} // namespace ROOT
69
70#endif
Uses standard C++ memory allocation for the column data pages.
RPage NewPage(std::size_t elementSize, std::size_t nElements) final
Reserves memory large enough to hold nElements of the given size.
void DeletePage(RPage &page) final
Releases the memory pointed to by page and resets the page's information.
Abstract interface to allocate and release pages.
virtual RPage NewPage(std::size_t elementSize, std::size_t nElements)=0
Reserves memory large enough to hold nElements of the given size.
virtual ~RPageAllocator()=default
virtual void DeletePage(RPage &page)=0
Releases the memory pointed to by page and resets the page's information.