Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RPageAllocator.hxx
Go to the documentation of this file.
1/// \file ROOT/RPageAllocator.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2019-06-25
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef ROOT7_RPageAllocator
17#define ROOT7_RPageAllocator
18
19#include <ROOT/RNTupleUtil.hxx>
20#include <ROOT/RPage.hxx>
21
22#include <cstddef>
23#include <functional>
24
25namespace ROOT {
26namespace Experimental {
27namespace Detail {
28
29// clang-format off
30/**
31\class ROOT::Experimental::Detail::RPageDeleter
32\ingroup NTuple
33\brief A closure that can free the memory associated with a mapped page
34
35The page pool, once taken ownership of pages, must know how to free them. When registering a new page with
36the page pool, the passed page deleter encapsulates that knowledge.
37*/
38// clang-format on
40private:
41 /// The callable that is suppped to free the given page; it is called with fUserData as the second argument.
42 std::function<void(const RPage &page, void *userData)> fFnDelete;
43 /// Optionally additional information necessary to free resources associated with a page. For instance,
44 /// when the page is read from a TKey, user data points to the ROOT object created for reading, which needs to be
45 /// freed as well.
46 void *fUserData;
47
48public:
49 RPageDeleter() : fFnDelete(), fUserData(nullptr) {}
50 explicit RPageDeleter(decltype(fFnDelete) fnDelete) : fFnDelete(fnDelete), fUserData(nullptr) {}
51 RPageDeleter(decltype(fFnDelete) fnDelete, void *userData) : fFnDelete(fnDelete), fUserData(userData) {}
52 RPageDeleter(const RPageDeleter &other) = default;
53 RPageDeleter &operator =(const RPageDeleter &other) = default;
54 ~RPageDeleter() = default;
55
56 void operator()(const RPage &page) { fFnDelete(page, fUserData); }
57};
58
59
60// clang-format off
61/**
62\class ROOT::Experimental::Detail::RPageAllocatorHeap
63\ingroup NTuple
64\brief Uses standard C++ memory allocation for the column data pages
65
66The page allocator acquires and releases memory for pages. It does not populate the pages, the returned pages
67are empty but guaranteed to have enough contiguous space for the given number of elements. While a common
68concrete implementation uses the heap, other implementations are possible, e.g. using arenas or mmap().
69*/
70// clang-format on
72public:
73 /// Reserves memory large enough to hold nElements of the given size. The page is immediately tagged with
74 /// a column id.
75 static RPage NewPage(ColumnId_t columnId, std::size_t elementSize, std::size_t nElements);
76 /// Releases the memory pointed to by page and resets the page's information
77 static void DeletePage(const RPage &page);
78};
79
80} // namespace Detail
81} // namespace Experimental
82} // namespace ROOT
83
84#endif
typedef void((*Func_t)())
Uses standard C++ memory allocation for the column data pages.
static RPage NewPage(ColumnId_t columnId, std::size_t elementSize, std::size_t nElements)
Reserves memory large enough to hold nElements of the given size.
static void DeletePage(const RPage &page)
Releases the memory pointed to by page and resets the page's information.
A closure that can free the memory associated with a mapped page.
RPageDeleter(const RPageDeleter &other)=default
RPageDeleter(decltype(fFnDelete) fnDelete, void *userData)
RPageDeleter & operator=(const RPageDeleter &other)=default
std::function< void(const RPage &page, void *userData)> fFnDelete
The callable that is suppped to free the given page; it is called with fUserData as the second argume...
RPageDeleter(decltype(fFnDelete) fnDelete)
void * fUserData
Optionally additional information necessary to free resources associated with a page.
A page is a slice of a column that is mapped into memory.
Definition RPage.hxx:41
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...