Scroom  0.14
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 >
boost::shared_ptr< R > shared_from_this ()
 
template<typename R >
boost::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 = boost::shared_ptr< BlockInterface >
 
using WeakPtr = boost::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  }

Referenced by create().

Here is the caller graph for this function:

Member Function Documentation

◆ create()

BlockInterface::Ptr Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::create ( size_t  count,
size_t  size 
)
static
70  {
72  }

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

Here is the call graph for this function:
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  }

◆ getPages()

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

Implements Scroom::MemoryBlocks::BlockInterface.

75  {
76  BlockInterface::Ptr const me = shared_from_this<BlockInterface>();
77 
78  PageList result;
79  for(size_t i = 0; i < count; i++)
80  {
81  result.emplace_back(me, i);
82  }
83 
84  return result;
85  }

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:
Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::SwapBasedBlockAllocator
SwapBasedBlockAllocator(size_t count, size_t size)
Definition: swapbasedblockallocator.cc:52
Scroom::MemoryBlocks::RawPageData::Ptr
boost::shared_ptr< uint8_t > Ptr
Definition: blockallocator.hh:23
Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::count
size_t count
Definition: swapbasedblockallocator.cc:37
Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::data
boost::movelib::unique_ptr< uint8_t[]> data
Definition: swapbasedblockallocator.cc:39
Scroom::MemoryBlocks::BlockInterface::Ptr
boost::shared_ptr< BlockInterface > Ptr
Definition: blockallocator.hh:46
Scroom::MemoryBlocks::PageList
std::list< Page > PageList
Definition: blockallocator.hh:41
Scroom::MemoryBlocks::Detail::SwapBasedBlockAllocator::size
size_t size
Definition: swapbasedblockallocator.cc:38