Barst  2.0
A server that controls lab hardware.
Public Member Functions | Public Attributes | List of all members
CMemRing Class Reference

#include <mem pool.h>

Public Member Functions

 CMemRing (__int64 ll_size, int nMinElems, int nMaxElems)
 
void * GetIndexMemory (int nIdx)
 
void * GetIndexMemoryUnsafe (int nIdx)
 
void ReleaseIndex (int nIdx)
 
void * GetFree (int *pnIdx)
 

Public Attributes

const __int64 m_llSize
 
const int m_nMinElems
 
const int m_nMaxElems
 

Detailed Description

A class which provides memory pointers and allows users to claim a pointer. If a memory items is claimed, that memory item is not returned until all that claimed it, release it. Multiple users can claim the same item. If there's no unclaimed memory, it creates some.

Definition at line 58 of file mem pool.h.

Constructor & Destructor Documentation

◆ CMemRing()

CMemRing::CMemRing ( __int64  ll_size,
int  nMinElems,
int  nMaxElems 
)

ll_size is the size that the memory blocks will be.

Definition at line 6 of file mem pool.cpp.

Member Function Documentation

◆ GetFree()

void * CMemRing::GetFree ( int *  pnIdx)

Returns a pointer of memory that is uncalimed. Creates one if it cannot find any. pnIdx gets the index value of the memory.

Definition at line 57 of file mem pool.cpp.

◆ GetIndexMemory()

void * CMemRing::GetIndexMemory ( int  nIdx)

Takes a index to memory item, returns the memory pointer, and adds a claim to the pointer.

Definition at line 26 of file mem pool.cpp.

◆ GetIndexMemoryUnsafe()

void * CMemRing::GetIndexMemoryUnsafe ( int  nIdx)

Takes a index to memory item, returns the memory pointer, however it does not add a claim to the pointer.

Definition at line 39 of file mem pool.cpp.

◆ ReleaseIndex()

void CMemRing::ReleaseIndex ( int  nIdx)

Releases a claim to a memory item.

Definition at line 49 of file mem pool.cpp.

Member Data Documentation

◆ m_llSize

const __int64 CMemRing::m_llSize

The size of the memory blocks.

Definition at line 78 of file mem pool.h.

◆ m_nMaxElems

const int CMemRing::m_nMaxElems

The maximum number of elements m_apMemory can ever have.

Definition at line 82 of file mem pool.h.

◆ m_nMinElems

const int CMemRing::m_nMinElems

The minimum number of elements m_apMemory can ever have.

Definition at line 80 of file mem pool.h.