join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicQueue< Policy > Class Template Reference

shared memory base class. More...

#include <shared.hpp>

Inheritance diagram for join::BasicQueue< Policy >:
Collaboration diagram for join::BasicQueue< Policy >:

Public Member Functions

 BasicQueue (const std::string &name, uint64_t elementSize=1472, uint64_t capacity=144)
 create instance.
 
 BasicQueue (const BasicQueue &other)=delete
 copy constructor.
 
BasicQueueoperator= (const BasicQueue &other)=delete
 copy assignment operator.
 
virtual ~BasicQueue ()
 destroy the instance.
 
int open () override
 open or create the shared memory segment.
 
void close () noexcept override
 close the shared memory segment.
 
const void * get (uint64_t offset=0) const override
 get a const pointer to the shared memory data region at a given offset.
 
void * get (uint64_t offset=0) override
 get a pointer to the shared memory data region at a given offset.
 
uint64_t elementSize () const noexcept
 get the element size of the shared memory region.
 
uint64_t capacity () const noexcept
 get the capacity of the shared memory region.
 
uint64_t size () const noexcept override
 get the size of the shared memory region.
 
- Public Member Functions inherited from join::SharedMemory
 SharedMemory (const std::string &name, uint64_t size)
 create instance.
 
virtual ~SharedMemory ()
 destroy the instance.
 
bool opened () const noexcept
 check if shared memory is opened.
 

Protected Attributes

Policy _policy
 shared memory segment policy.
 
uint64_t _elementSize = 0
 shared memory segment element size.
 
uint64_t _capacity = 0
 shared memory segment capacity.
 
uint64_t _totalSize = 0
 total shared memory size.
 
uint64_t _userSize = 0
 user shared memory size.
 
SharedSegment_segment = nullptr
 shared memory segment.
 
- Protected Attributes inherited from join::SharedMemory
std::string _name
 shared memory name.
 
uint64_t _size = 0
 shared memory size.
 
void * _ptr = nullptr
 pointer to mapped shared memory.
 
int _fd = -1
 shared memory file descriptor.
 

Additional Inherited Members

- Static Public Member Functions inherited from join::SharedMemory
static int unlink (const std::string &name) noexcept
 destroy synchronization primitives and unlink the shared memory segment.
 

Detailed Description

template<typename Policy>
class join::BasicQueue< Policy >

shared memory base class.

Constructor & Destructor Documentation

◆ BasicQueue() [1/2]

template<typename Policy >
join::BasicQueue< Policy >::BasicQueue ( const std::string & name,
uint64_t elementSize = 1472,
uint64_t capacity = 144 )
inline

create instance.

Parameters
nameshared memory segment name.
elementSizeshared memory segment element size.
capacityshared memory segment capacity.

◆ BasicQueue() [2/2]

template<typename Policy >
join::BasicQueue< Policy >::BasicQueue ( const BasicQueue< Policy > & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ ~BasicQueue()

template<typename Policy >
virtual join::BasicQueue< Policy >::~BasicQueue ( )
inlinevirtual

destroy the instance.

Member Function Documentation

◆ capacity()

template<typename Policy >
uint64_t join::BasicQueue< Policy >::capacity ( ) const
inlinenoexcept

get the capacity of the shared memory region.

Returns
shared memory capacity.

◆ close()

template<typename Policy >
void join::BasicQueue< Policy >::close ( )
inlineoverridevirtualnoexcept

close the shared memory segment.

Reimplemented from join::SharedMemory.

◆ elementSize()

template<typename Policy >
uint64_t join::BasicQueue< Policy >::elementSize ( ) const
inlinenoexcept

get the element size of the shared memory region.

Returns
shared memory element size in bytes.

◆ get() [1/2]

template<typename Policy >
const void * join::BasicQueue< Policy >::get ( uint64_t offset = 0) const
inlineoverridevirtual

get a const pointer to the shared memory data region at a given offset.

Parameters
offsetbyte offset from the start of the data region.
Returns
pointer to the data region at the specified offset, or nullptr if not opened.
Exceptions
std::out_of_rangeif offset is out of bounds.

Reimplemented from join::SharedMemory.

◆ get() [2/2]

template<typename Policy >
void * join::BasicQueue< Policy >::get ( uint64_t offset = 0)
inlineoverridevirtual

get a pointer to the shared memory data region at a given offset.

Parameters
offsetbyte offset from the start of the data region.
Returns
pointer to the data region at the specified offset, or nullptr if not opened.
Exceptions
std::out_of_rangeif offset is out of bounds.

Reimplemented from join::SharedMemory.

◆ open()

template<typename Policy >
int join::BasicQueue< Policy >::open ( )
inlineoverridevirtual

open or create the shared memory segment.

Returns
0 on success, -1 on failure.

Reimplemented from join::SharedMemory.

◆ operator=()

template<typename Policy >
BasicQueue & join::BasicQueue< Policy >::operator= ( const BasicQueue< Policy > & other)
delete

copy assignment operator.

Parameters
otherother object to assign.
Returns
assigned object.

◆ size()

template<typename Policy >
uint64_t join::BasicQueue< Policy >::size ( ) const
inlineoverridevirtualnoexcept

get the size of the shared memory region.

Returns
shared memory size in bytes.

Reimplemented from join::SharedMemory.

Member Data Documentation

◆ _capacity

template<typename Policy >
uint64_t join::BasicQueue< Policy >::_capacity = 0
protected

shared memory segment capacity.

◆ _elementSize

template<typename Policy >
uint64_t join::BasicQueue< Policy >::_elementSize = 0
protected

shared memory segment element size.

◆ _policy

template<typename Policy >
Policy join::BasicQueue< Policy >::_policy
protected

shared memory segment policy.

◆ _segment

template<typename Policy >
SharedSegment* join::BasicQueue< Policy >::_segment = nullptr
protected

shared memory segment.

◆ _totalSize

template<typename Policy >
uint64_t join::BasicQueue< Policy >::_totalSize = 0
protected

total shared memory size.

◆ _userSize

template<typename Policy >
uint64_t join::BasicQueue< Policy >::_userSize = 0
protected

user shared memory size.


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