XRootD
Loading...
Searching...
No Matches
XrdPfc::StableChunkPool< T, InnerShift, MaxChunks > Class Template Reference

#include <XrdPfcStableChunkVector.hh>

+ Inheritance diagram for XrdPfc::StableChunkPool< T, InnerShift, MaxChunks >:
+ Collaboration diagram for XrdPfc::StableChunkPool< T, InnerShift, MaxChunks >:

Public Member Functions

int acquire ()
 
std::size_t n_free () const
 
std::size_t n_in_use () const
 
void release (int i)
 Clear the slot and return it for reuse. Caller must hold its mutex.
 
- Public Member Functions inherited from XrdPfc::StableChunkVector< T, 12, 1024 >
 StableChunkVector ()
 
int add ()
 Append a default-constructed T; return its index, or -1 if full.
 
std::size_t capacity () const
 
bool full () const
 
T & operator[] (std::size_t i)
 
const T & operator[] (std::size_t i) const
 
std::size_t size () const
 

Additional Inherited Members

- Static Public Attributes inherited from XrdPfc::StableChunkVector< T, 12, 1024 >
static constexpr std::size_t s_capacity
 
static constexpr std::size_t s_chunk_mask
 
static constexpr std::size_t s_chunk_size
 

Detailed Description

template<typename T, unsigned InnerShift = 12, unsigned MaxChunks = 1024>
class XrdPfc::StableChunkPool< T, InnerShift, MaxChunks >

StableChunkVector with slot recycling. Not thread-safe: acquire() and release() must run under the mutex that also publishes the index. release() clears the slot, so acquire() always returns a cleared one. Requires T::clear().

Definition at line 71 of file XrdPfcStableChunkVector.hh.

Member Function Documentation

◆ acquire()

template<typename T, unsigned InnerShift = 12, unsigned MaxChunks = 1024>
int XrdPfc::StableChunkPool< T, InnerShift, MaxChunks >::acquire ( )
inline

Index of a recycled or freshly appended slot, cleared and ready for use, or -1 if capacity is exhausted. Caller must hold its mutex.

Definition at line 78 of file XrdPfcStableChunkVector.hh.

79 {
80 if ( ! m_free_slots.empty())
81 {
82 int i = m_free_slots.back();
83 m_free_slots.pop_back();
84 return i;
85 }
86 return Base::add();
87 }

References XrdPfc::StableChunkVector< T, InnerShift, MaxChunks >::add().

+ Here is the call graph for this function:

◆ n_free()

template<typename T, unsigned InnerShift = 12, unsigned MaxChunks = 1024>
std::size_t XrdPfc::StableChunkPool< T, InnerShift, MaxChunks >::n_free ( ) const
inline

Definition at line 96 of file XrdPfcStableChunkVector.hh.

96{ return m_free_slots.size(); }

◆ n_in_use()

template<typename T, unsigned InnerShift = 12, unsigned MaxChunks = 1024>
std::size_t XrdPfc::StableChunkPool< T, InnerShift, MaxChunks >::n_in_use ( ) const
inline

Definition at line 97 of file XrdPfcStableChunkVector.hh.

97{ return Base::size() - m_free_slots.size(); }

References XrdPfc::StableChunkVector< T, InnerShift, MaxChunks >::size().

+ Here is the call graph for this function:

◆ release()

template<typename T, unsigned InnerShift = 12, unsigned MaxChunks = 1024>
void XrdPfc::StableChunkPool< T, InnerShift, MaxChunks >::release ( int i)
inline

Clear the slot and return it for reuse. Caller must hold its mutex.

Definition at line 90 of file XrdPfcStableChunkVector.hh.

91 {
92 (*this)[i].clear();
93 m_free_slots.push_back(i);
94 }

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