STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions | Static Public Member Functions
stapl::runtime::object_storage< T > Class Template Reference

Storage for objects used in communication over shared memory. More...

Public Member Functions

 object_storage (object_storage const &)=delete
 
object_storageoperator= (object_storage const &)=delete
 
bool construct (T &&t, void *const base, std::size_t &size)
 Initializes this object by moving t in it. More...
 
bool construct (T const &t, void *const base, std::size_t &size)
 Initializes this object by copying t in it. More...
 
void destroy (void) noexcept
 Destroys the internal storage as if it holds a moved or copied object.
 
void destroy_packed (void) noexcept
 Destroys the internal storage as if it holds a packed object.
 
T & get (void) noexcept
 Returns the moved or copied object.
 
T & get (void *const base)
 Returns the stored object after unpacking it. More...
 
T & get (void *const base, std::size_t &size)
 Returns the stored object after unpacking it. More...
 
moveout (void)
 Moves the object out if it was moved or copied in.
 

Static Public Member Functions

static std::size_t packed_size (T &&t) noexcept
 Returns the packed size of t.
 
static std::size_t packed_size (T const &t) noexcept
 Returns the packed size of t.
 

Detailed Description

template<typename T>
class stapl::runtime::object_storage< T >

Storage for objects used in communication over shared memory.

Template Parameters
TObject type.

This class uses a properly aligned char array to store an object of type T. Determined by typer_traits::meets_requirements(), the object is either copied or moved in this array. Otherwise, the static part of the object is copied in the array, while the dynamic part (e.g. any heap allocated space that a member of T points to) will be copied in the extra space during packing in construct().

Warning
One of the destroy() or destroy_packed() functions has to be called prior to the destructor to avoid memory leaks.
There can be only a single call to the get(), moveout(), get(void*const) or get(void*const,std::size_t&) functions.
See also
packed_object_storage

Member Function Documentation

◆ construct() [1/2]

template<typename T >
bool stapl::runtime::object_storage< T >::construct ( T &&  t,
void *const  base,
std::size_t &  size 
)

Initializes this object by moving t in it.

Warning
This function can only be called if the object has been default constructed.
Returns
true if t was moved, otherwise false.

◆ construct() [2/2]

template<typename T >
bool stapl::runtime::object_storage< T >::construct ( T const &  t,
void *const  base,
std::size_t &  size 
)

Initializes this object by copying t in it.

Warning
This function can only be called if the object has been default constructed.
Returns
true if t was copied, otherwise false.

◆ get() [1/2]

template<typename T >
T& stapl::runtime::object_storage< T >::get ( void *const  base)

Returns the stored object after unpacking it.

Parameters
baseBuffer where the dynamic part of the object is stored.

◆ get() [2/2]

template<typename T >
T& stapl::runtime::object_storage< T >::get ( void *const  base,
std::size_t &  size 
)

Returns the stored object after unpacking it.

Parameters
baseBuffer where the dynamic part of the object is stored.
sizeVariable to store how many bytes were unpacked.

Member Data Documentation

◆ m_force_alignment

template<typename T >
aligned_storage_t<sizeof(T)> stapl::runtime::object_storage< T >::m_force_alignment

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