MCPcopy Create free account
hub / github.com/Haivision/srt / getNextAvailUnit

Method getNextAvailUnit

srtcore/queue.cpp:157–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157srt::CUnit* srt::CUnitQueue::getNextAvailUnit()
158{
159 const int iNumUnitsTotal = capacity();
160 if (m_iNumTaken * 10 > iNumUnitsTotal * 9) // 90% or more are in use.
161 increase_();
162
163 if (m_iNumTaken >= capacity())
164 {
165 LOGC(qrlog.Error, log << "CUnitQueue: No free units to take. Capacity" << capacity() << ".");
166 return NULL;
167 }
168
169 int units_checked = 0;
170 do
171 {
172 const CUnit* end = m_pCurrQueue->m_pUnit + m_pCurrQueue->m_iSize;
173 for (; m_pAvailUnit != end; ++m_pAvailUnit, ++units_checked)
174 {
175 if (!m_pAvailUnit->m_bTaken)
176 {
177 return m_pAvailUnit;
178 }
179 }
180
181 m_pCurrQueue = m_pCurrQueue->m_pNext;
182 m_pAvailUnit = m_pCurrQueue->m_pUnit;
183 } while (units_checked < m_iSize);
184
185 return NULL;
186}
187
188void srt::CUnitQueue::makeUnitFree(CUnit* unit)
189{

Callers 4

worker_RetrieveUnitMethod · 0.80
InsertRebuiltMethod · 0.80
TESTFunction · 0.80
addPacketMethod · 0.80

Calls

no outgoing calls

Tested by 2

TESTFunction · 0.64
addPacketMethod · 0.64