Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator Class Reference
Inheritance diagram for Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator:
Inheritance graph
Collaboration diagram for Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator:
Collaboration graph

Public Member Functions

PageList getPages () override
 
- Public Member Functions inherited from Scroom::Utils::Base
 Base ()=default
 
 Base (const Base &)=delete
 
 Base (Base &&)=delete
 
Baseoperator= (const Base &)=delete
 
Baseoperator= (Base &&)=delete
 
virtual ~Base ()=default
 
template<typename R >
std::shared_ptr< R > shared_from_this ()
 
template<typename R >
std::shared_ptr< R const > shared_from_this () const
 

Static Public Member Functions

static BlockInterface::Ptr create (size_t count, size_t size)
 

Protected Member Functions

RawPageData::Ptr get (size_t id) override
 

Private Member Functions

 SwapBasedBlockAllocator (size_t count, size_t size)
 

Private Attributes

size_t count
 
size_t size
 
boost::movelib::unique_ptr< uint8_t[]> data
 

Additional Inherited Members

- Public Types inherited from Scroom::MemoryBlocks::BlockInterface
using Ptr = std::shared_ptr< BlockInterface >
 
using WeakPtr = std::weak_ptr< BlockInterface >
 

Constructor & Destructor Documentation

◆ SwapBasedBlockAllocator()

Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::SwapBasedBlockAllocator ( size_t  count,
size_t  size 
)
private
53 : count(count_)
54 , size(size_)
55 , data(boost::movelib::make_unique<uint8_t[]>(count_ * size_))
56 {
57 }
size_t count
Definition swapbasedblockallocator.cc:37
size_t size
Definition swapbasedblockallocator.cc:38
boost::movelib::unique_ptr< uint8_t[]> data
Definition swapbasedblockallocator.cc:39

Member Function Documentation

◆ create()

BlockInterface::Ptr Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::create ( size_t  count,
size_t  size 
)
static
70 {
72 }
std::shared_ptr< BlockInterface > Ptr
Definition blockallocator.hh:44
SwapBasedBlockAllocator(size_t count, size_t size)
Definition swapbasedblockallocator.cc:52

Referenced by Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocatorFactory::create().

Here is the caller graph for this function:

◆ get()

RawPageData::Ptr Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::get ( size_t  id)
overrideprotectedvirtual

Implements Scroom::MemoryBlocks::BlockInterface.

60 {
61 if(id >= count)
62 {
63 throw std::out_of_range("");
64 }
65
66 return RawPageData::Ptr(shared_from_this<SwapBasedBlockAllocator>(), data.get() + id * size);
67 }
std::shared_ptr< uint8_t > Ptr
Definition blockallocator.hh:21

◆ getPages()

PageList Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::getPages ( )
overridevirtual

Implements Scroom::MemoryBlocks::BlockInterface.

75 {
76 BlockInterface::Ptr const me = shared_from_this<BlockInterface>();
77
79 for(size_t i = 0; i < count; i++)
80 {
81 result.emplace_back(me, i);
82 }
83
84 return result;
85 }
std::list< Page > PageList
Definition blockallocator.hh:39
SampleIterator< const uint8_t > result
Definition sampleiterator-tests.cc:94

Member Data Documentation

◆ count

size_t Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::count
private

Referenced by create(), get(), and getPages().

◆ data

boost::movelib::unique_ptr<uint8_t[]> Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::data
private

Referenced by get().

◆ size

size_t Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::size
private

Referenced by create(), and get().


The documentation for this class was generated from the following file: