Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::ParallelComm::Buffer Class Reference

#include <ParallelComm.hpp>

Public Member Functions

 Buffer (unsigned int sz=0)
 
 Buffer (const Buffer &)
 
 ~Buffer ()
 
void reset_buffer (size_t buff_pos=0)
 
void reset_ptr (size_t buff_pos=0)
 
void reserve (unsigned int new_size)
 
void set_stored_size ()
 
int get_stored_size ()
 
int get_current_size ()
 
void check_space (unsigned int addl_space)
 

Public Attributes

unsigned char * mem_ptr
 
unsigned char * buff_ptr
 
unsigned int alloc_size
 

Detailed Description

Definition at line 786 of file ParallelComm.hpp.

Constructor & Destructor Documentation

◆ Buffer() [1/2]

moab::ParallelComm::Buffer::Buffer ( unsigned int  sz = 0)
inline

Definition at line 1492 of file ParallelComm.hpp.

1492  : mem_ptr( NULL ), buff_ptr( NULL ), alloc_size( 0 )
1493 {
1494  if( new_size ) this->reserve( new_size );
1495 }

References reserve().

◆ Buffer() [2/2]

moab::ParallelComm::Buffer::Buffer ( const Buffer other_buff)
inline

Definition at line 1484 of file ParallelComm.hpp.

1485 {
1486  alloc_size = other_buff.alloc_size;
1487  mem_ptr = (unsigned char*)malloc( alloc_size );
1488  memcpy( mem_ptr, other_buff.mem_ptr, alloc_size );
1489  buff_ptr = mem_ptr + ( other_buff.buff_ptr - other_buff.mem_ptr );
1490 }

References alloc_size, buff_ptr, and mem_ptr.

◆ ~Buffer()

moab::ParallelComm::Buffer::~Buffer ( )
inline

Definition at line 1497 of file ParallelComm.hpp.

1498 {
1499  if( mem_ptr )
1500  {
1501  free( mem_ptr );
1502  mem_ptr = NULL;
1503  }
1504 }

Member Function Documentation

◆ check_space()

void moab::ParallelComm::Buffer::check_space ( unsigned int  addl_space)
inline

◆ get_current_size()

int moab::ParallelComm::Buffer::get_current_size ( )
inline

Definition at line 815 of file ParallelComm.hpp.

816  {
817  return (int)( buff_ptr - mem_ptr );
818  }

References buff_ptr, and mem_ptr.

Referenced by moab::ParallelComm::pack_entity_seq().

◆ get_stored_size()

int moab::ParallelComm::Buffer::get_stored_size ( )
inline

Definition at line 811 of file ParallelComm.hpp.

812  {
813  return *( (int*)mem_ptr );
814  }

References mem_ptr.

Referenced by moab::ParallelComm::recv_buffer(), and moab::ParallelComm::send_buffer().

◆ reserve()

void moab::ParallelComm::Buffer::reserve ( unsigned int  new_size)
inline

Definition at line 1508 of file ParallelComm.hpp.

1509 {
1510 
1511 #ifdef DEBUG_BUFFER
1512  int tmp_pos = 0;
1513  if( mem_ptr )
1514  {
1515  tmp_pos = buff_ptr - mem_ptr;
1516  }
1517  buff_ptr = (unsigned char*)malloc( new_size );
1518  assert( 0 <= tmp_pos && tmp_pos <= (int)alloc_size );
1519  if( tmp_pos ) memcpy( buff_ptr, mem_ptr, tmp_pos );
1520  if( mem_ptr ) free( mem_ptr );
1521  mem_ptr = buff_ptr;
1522  alloc_size = new_size;
1523  buff_ptr = mem_ptr + tmp_pos;
1524 #else
1525  if( mem_ptr && alloc_size < new_size )
1526  {
1527  size_t tmp_pos = mem_ptr ? buff_ptr - mem_ptr : 0;
1528  mem_ptr = (unsigned char*)realloc( mem_ptr, new_size );
1529  alloc_size = new_size;
1530  buff_ptr = mem_ptr + tmp_pos;
1531  }
1532  else if( !mem_ptr )
1533  {
1534  mem_ptr = (unsigned char*)malloc( new_size );
1535  alloc_size = new_size;
1536  buff_ptr = mem_ptr;
1537  }
1538 #endif
1539 }

Referenced by moab::ParallelComm::broadcast_entities(), Buffer(), moab::ParallelComm::recv_buffer(), reset_buffer(), and moab::ParallelComm::scatter_entities().

◆ reset_buffer()

void moab::ParallelComm::Buffer::reset_buffer ( size_t  buff_pos = 0)
inline

Definition at line 796 of file ParallelComm.hpp.

797  {
798  reset_ptr( buff_pos );
800  }

References moab::ParallelComm::INITIAL_BUFF_SIZE, reserve(), and reset_ptr().

◆ reset_ptr()

void moab::ParallelComm::Buffer::reset_ptr ( size_t  buff_pos = 0)
inline

Definition at line 801 of file ParallelComm.hpp.

802  {
803  assert( ( !mem_ptr && !buff_pos ) || ( alloc_size >= buff_pos ) );
804  buff_ptr = mem_ptr + buff_pos;
805  }

References alloc_size, buff_ptr, and mem_ptr.

Referenced by moab::ParallelComm::broadcast_entities(), moab::ParallelComm::recv_buffer(), reset_buffer(), moab::ParallelComm::scatter_entities(), and moab::ParallelComm::settle_intersection_points().

◆ set_stored_size()

Member Data Documentation

◆ alloc_size

unsigned int moab::ParallelComm::Buffer::alloc_size

◆ buff_ptr

◆ mem_ptr


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