Loading...
Searching...
No Matches
XrdNetBufferQ Class Reference

`#include <XrdNetBuffer.hh>`

Collaboration diagram for XrdNetBufferQ:

## Public Member Functions

| XrdNetBufferQ (int bsz, int maxb=16)
| ~XrdNetBufferQ ()
XrdNetBuffer * | Alloc ()
int | BuffSize (void)
void | Recycle (XrdNetBuffer *bp)
void | Set (int maxb)

## Public Attributes

int | alignit
XrdSysMutex | BuffList
XrdOucStack< XrdNetBuffer > | BuffStack
int | maxbuff
int | numbuff
int | size

## Detailed Description

Definition at line 44 of file XrdNetBuffer.hh.

## Constructor & Destructor Documentation

## XrdNetBufferQ()

XrdNetBufferQ::XrdNetBufferQ | ( | int | bsz,
|  | int | maxb = 16 )

Definition at line 47 of file XrdNetBuffer.cc.

{
size = bsz;
alignit = (size < sysconf(_SC_PAGESIZE)
? size : sysconf(_SC_PAGESIZE));
maxbuff = maxb;
numbuff = 0;
}
XrdNetBufferQ::alignit
int alignit
Definition XrdNetBuffer.hh:59
XrdNetBufferQ::numbuff
int numbuff
Definition XrdNetBuffer.hh:63
XrdNetBufferQ::size
int size
Definition XrdNetBuffer.hh:64
XrdNetBufferQ::maxbuff
int maxbuff
Definition XrdNetBuffer.hh:62

References alignit, maxbuff, numbuff, and size.

## ~XrdNetBufferQ()

XrdNetBufferQ::~XrdNetBufferQ | ( |  | ) |

Definition at line 60 of file XrdNetBuffer.cc.

{
XrdNetBuffer *bp;
while((bp = BuffStack.Pop())) delete bp;
}
XrdNetBufferQ::BuffStack
XrdOucStack< XrdNetBuffer > BuffStack
Definition XrdNetBuffer.hh:61

References BuffStack.

## Member Function Documentation

## Alloc()

XrdNetBuffer * XrdNetBufferQ::Alloc | ( |  | ) |

Definition at line 71 of file XrdNetBuffer.cc.

{
XrdNetBuffer *bp;
// Lock the data area
//
BuffList.Lock();
// Either return a new buffer or an old one
//
if ((bp = BuffStack.Pop())) numbuff--;
else if ((bp = new XrdNetBuffer(this))
&& posix_memalign((void **)&(bp->data), alignit, size))
{delete bp; bp = 0;}
// Unlock the data area
//
BuffList.UnLock();
// Return the buffer
//
return bp;
}
XrdNetBufferQ::BuffList
XrdSysMutex BuffList
Definition XrdNetBuffer.hh:60
XrdNetBuffer::data
char * data
Definition XrdNetBuffer.hh:76

References alignit, BuffList, BuffStack, XrdNetBuffer::data, numbuff, and size.

## BuffSize()

int XrdNetBufferQ::BuffSize | ( | void |  | ) |

inline

Definition at line 50 of file XrdNetBuffer.hh.

{return size;}

References size.

## Recycle()

void XrdNetBufferQ::Recycle | ( | XrdNetBuffer * | bp | ) |

Definition at line 99 of file XrdNetBuffer.cc.

{
// Check if we have enough objects, if so, delete ourselves and return
//
if (numbuff >= maxbuff) {delete bp; return;}
bp->dlen = 0;
// Add the buffer to the recycle list
//
BuffList.Lock();
BuffStack.Push(&bp->BuffLink);
numbuff++;
BuffList.UnLock();
return;
}
XrdNetBuffer::dlen
int dlen
Definition XrdNetBuffer.hh:77

References BuffList, BuffStack, XrdNetBuffer::dlen, maxbuff, and numbuff.

## Set()

void XrdNetBufferQ::Set | ( | int | maxb | ) |

Definition at line 120 of file XrdNetBuffer.cc.

{
// Lock the data area, set max buffers, unlock and return
//
BuffList.Lock();
maxbuff = maxb;
BuffList.UnLock();
return;
}

References BuffList, and maxbuff.

## Member Data Documentation

## alignit

int XrdNetBufferQ::alignit

Definition at line 59 of file XrdNetBuffer.hh.

Referenced by XrdNetBufferQ(), and Alloc().

## BuffList

XrdSysMutex XrdNetBufferQ::BuffList

Definition at line 60 of file XrdNetBuffer.hh.

Referenced by Alloc(), Recycle(), and Set().

## BuffStack

XrdOucStack<XrdNetBuffer> XrdNetBufferQ::BuffStack

Definition at line 61 of file XrdNetBuffer.hh.

Referenced by ~XrdNetBufferQ(), Alloc(), and Recycle().

## maxbuff

int XrdNetBufferQ::maxbuff

Definition at line 62 of file XrdNetBuffer.hh.

Referenced by XrdNetBufferQ(), Recycle(), and Set().

## numbuff

int XrdNetBufferQ::numbuff

Definition at line 63 of file XrdNetBuffer.hh.

Referenced by XrdNetBufferQ(), Alloc(), and Recycle().

## size

int XrdNetBufferQ::size

Definition at line 64 of file XrdNetBuffer.hh.

Referenced by XrdNetBufferQ(), Alloc(), and BuffSize().

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

- XrdNetBuffer.hh
- XrdNetBuffer.cc