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

#include <XrdNetBuffer.hh>

Collaboration diagram for XrdNetBufferQ:

Public Member Functions

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

Public Attributes

int alignit
XrdSysMutex BuffList
XrdOucStack< XrdNetBufferBuffStack
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.

48{
49 size = bsz;
50 alignit = (size < sysconf(_SC_PAGESIZE)
51 ? size : sysconf(_SC_PAGESIZE));
52 maxbuff = maxb;
53 numbuff = 0;
54}

References alignit, maxbuff, numbuff, and size.

◆ ~XrdNetBufferQ()

XrdNetBufferQ::~XrdNetBufferQ ( )

Definition at line 60 of file XrdNetBuffer.cc.

61{
62 XrdNetBuffer *bp;
63
64 while((bp = BuffStack.Pop())) delete bp;
65}
XrdOucStack< XrdNetBuffer > BuffStack

References BuffStack.

Member Function Documentation

◆ Alloc()

XrdNetBuffer * XrdNetBufferQ::Alloc ( )

Definition at line 71 of file XrdNetBuffer.cc.

72{
73 XrdNetBuffer *bp;
74
75// Lock the data area
76//
77 BuffList.Lock();
78
79// Either return a new buffer or an old one
80//
81 if ((bp = BuffStack.Pop())) numbuff--;
82 else if ((bp = new XrdNetBuffer(this))
83 && posix_memalign((void **)&(bp->data), alignit, size))
84 {delete bp; bp = 0;}
85
86// Unlock the data area
87//
88 BuffList.UnLock();
89
90// Return the buffer
91//
92 return bp;
93}
XrdSysMutex BuffList

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

◆ BuffSize()

int XrdNetBufferQ::BuffSize ( void )
inline

Definition at line 50 of file XrdNetBuffer.hh.

50{return size;}

References size.

◆ Recycle()

void XrdNetBufferQ::Recycle ( XrdNetBuffer * bp)

Definition at line 99 of file XrdNetBuffer.cc.

100{
101
102// Check if we have enough objects, if so, delete ourselves and return
103//
104 if (numbuff >= maxbuff) {delete bp; return;}
105 bp->dlen = 0;
106
107// Add the buffer to the recycle list
108//
109 BuffList.Lock();
110 BuffStack.Push(&bp->BuffLink);
111 numbuff++;
112 BuffList.UnLock();
113 return;
114}

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

◆ Set()

void XrdNetBufferQ::Set ( int maxb)

Definition at line 120 of file XrdNetBuffer.cc.

121{
122
123// Lock the data area, set max buffers, unlock and return
124//
125 BuffList.Lock();
126 maxbuff = maxb;
127 BuffList.UnLock();
128 return;
129}

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: