ATLAS Offline Software
LWPool.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 //____________________________________________________________________
7 inline char* LWPool::acquire()
8 {
9  std::scoped_lock lock (m_mutex);
10  char * c = (m_likelyNonEmptyArea?m_likelyNonEmptyArea->acquire():0);
11  return c ? c : searchAcquire();
12 }
13 
14 
15 //____________________________________________________________________
16 inline bool LWPool::belongsInArea(char*c,LWPoolArea*a) const
17 {
18  return c>reinterpret_cast<char*>(a) && c<reinterpret_cast<char*>(a)+m_growsize;
19 }
20 
21 //____________________________________________________________________
22 inline void LWPool::release(char*c)
23 {
24  std::scoped_lock lock (m_mutex);
25  assert(!m_likelyReleaseArea||(m_likelyReleaseArea->belongsInArea(c)==belongsInArea(c,m_likelyReleaseArea)));
26  if (!m_likelyReleaseArea||!belongsInArea(c,m_likelyReleaseArea))
27  m_likelyReleaseArea = findArea(c);
28  assert(m_likelyReleaseArea);
29  m_likelyReleaseArea->release(c);
30  if (m_likelyReleaseArea->isUnused()&&!isMotherPool()) {//NB: Mother pool never releases!!!!
31  // cppcheck-suppress thisUseAfterFree; xxx check this!
32  freeArea(m_likelyReleaseArea);
33  }
34 }