XRootD
XrdCl::BufferPool Class Reference

Buffer pool - to limit memory consumption. More...

+ Collaboration diagram for XrdCl::BufferPool:

Public Member Functions

std::shared_ptr< std::vector< char > > Allocate (size_t length)
 

Static Public Member Functions

static BufferPoolInstance ()
 Single instance access. More...
 

Detailed Description

Buffer pool - to limit memory consumption.

Definition at line 56 of file XrdClReplay.cc.

Member Function Documentation

◆ Allocate()

std::shared_ptr<std::vector<char> > XrdCl::BufferPool::Allocate ( size_t  length)
inline

Allocate a buffer if has available memory, otherwise wait until enough memory has been reclaimed

Definition at line 73 of file XrdClReplay.cc.

74  {
75  std::unique_lock<std::mutex> lck( mtx );
76  cv.wait( lck, [this, length]{ return available >= length; } );
77  available -= length;
78  BufferDeleter del;
79  std::shared_ptr<std::vector<char>> buffer( new std::vector<char>( length, 'A' ), del );
80  return buffer;
81  }

◆ Instance()

static BufferPool& XrdCl::BufferPool::Instance ( )
inlinestatic

Single instance access.

Definition at line 63 of file XrdClReplay.cc.

64  {
65  static BufferPool instance;
66  return instance;
67  }

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