OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
BMemory< Memory > Class Template Reference

It override the behavior if size() More...

Detailed Description

template<typename Memory>
class BMemory< Memory >

It override the behavior if size()

On normal memory like HeapMemory if you try to use resize to shrink the memory, nothing happen and size() return the old size. In case of BMemory<HeapMemory> if you try to shrink still the memory is not shrinked, but size() return the shrinked size. This gives a "feeling" of shrinkage. The real internal size can be retrieved with msize(). When we use resize to increase the memory size the behaviour remain the same as normal HeapMemory.

Note
this wrapper can be used in combination also with CudaMemory

Allocate memory

Resize memory

Shrink memory

Definition at line 46 of file BHeapMemory.hpp.

#include <BHeapMemory.hpp>

+ Inheritance diagram for BMemory< Memory >:

Public Member Functions

 BMemory (const BMemory< Memory > &mem)
 Copy the Heap memory.
 
 BMemory (BMemory< Memory > &&mem) noexcept
 Copy the Heap memory.
 
 BMemory ()
 Constructor, we choose a default alignment of 32 for avx.
 
virtual ~BMemory () noexcept
 Destructor.
 
virtual bool allocate (size_t sz)
 allocate the memory
 
virtual bool resize (size_t sz)
 Resize the allocated memory.
 
virtual size_t size () const
 Resize the buffer size.
 
size_t msize ()
 Return the memory size.
 
BMemoryoperator= (const BMemory< Memory > &mem)
 Copy the memory.
 
BMemoryoperator= (BMemory< Memory > &&mem)
 Copy the memory.
 
void destroy ()
 Destroy the internal memory.
 
void swap (BMemory< Memory > &mem)
 swap the two memory object
 

Private Attributes

size_t buf_sz
 size of the memory
 

Constructor & Destructor Documentation

◆ BMemory() [1/3]

template<typename Memory >
BMemory< Memory >::BMemory ( const BMemory< Memory > &  mem)
inline

Copy the Heap memory.

Parameters
memmemory to copy

Definition at line 58 of file BHeapMemory.hpp.

◆ BMemory() [2/3]

template<typename Memory >
BMemory< Memory >::BMemory ( BMemory< Memory > &&  mem)
inlinenoexcept

Copy the Heap memory.

Parameters
memmemory to copy

Definition at line 68 of file BHeapMemory.hpp.

◆ BMemory() [3/3]

template<typename Memory >
BMemory< Memory >::BMemory ( )
inline

Constructor, we choose a default alignment of 32 for avx.

Definition at line 74 of file BHeapMemory.hpp.

◆ ~BMemory()

template<typename Memory >
virtual BMemory< Memory >::~BMemory ( )
inlinevirtualnoexcept

Destructor.

Definition at line 79 of file BHeapMemory.hpp.

Member Function Documentation

◆ allocate()

template<typename Memory >
virtual bool BMemory< Memory >::allocate ( size_t  sz)
inlinevirtual

allocate the memory

Resize the allocated memory, if request is smaller than the allocated memory is not resized

Parameters
szsize
Returns
true if the resize operation complete correctly

Definition at line 92 of file BHeapMemory.hpp.

◆ destroy()

template<typename Memory >
void BMemory< Memory >::destroy ( )
inline

Destroy the internal memory.

Definition at line 177 of file BHeapMemory.hpp.

◆ msize()

template<typename Memory >
size_t BMemory< Memory >::msize ( )
inline

Return the memory size.

Returns
The allocated memory size

Definition at line 138 of file BHeapMemory.hpp.

◆ operator=() [1/2]

template<typename Memory >
BMemory & BMemory< Memory >::operator= ( BMemory< Memory > &&  mem)
inline

Copy the memory.

Parameters
memmemory to copy
Returns
itself

Definition at line 165 of file BHeapMemory.hpp.

◆ operator=() [2/2]

template<typename Memory >
BMemory & BMemory< Memory >::operator= ( const BMemory< Memory > &  mem)
inline

Copy the memory.

Parameters
memmemory to copy
Returns
itself

Definition at line 150 of file BHeapMemory.hpp.

◆ resize()

template<typename Memory >
virtual bool BMemory< Memory >::resize ( size_t  sz)
inlinevirtual

Resize the allocated memory.

Resize the allocated memory, if request is smaller than the allocated memory is not resized

Parameters
szsize
Returns
true if the resize operation complete correctly

Definition at line 111 of file BHeapMemory.hpp.

◆ size()

template<typename Memory >
virtual size_t BMemory< Memory >::size ( ) const
inlinevirtual

Resize the buffer size.

Returns
the buffer size

Definition at line 127 of file BHeapMemory.hpp.

◆ swap()

template<typename Memory >
void BMemory< Memory >::swap ( BMemory< Memory > &  mem)
inline

swap the two memory object

Parameters
memMemory to swap with

Definition at line 188 of file BHeapMemory.hpp.

Field Documentation

◆ buf_sz

template<typename Memory >
size_t BMemory< Memory >::buf_sz
private

size of the memory

Definition at line 49 of file BHeapMemory.hpp.


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