FACT++  1.0
void MemoryStock::push ( const std::shared_ptr< char > &  mem)
inlineprivate

Definition at line 81 of file MemoryManager.h.

82  {
83  if (!mem)
84  return;
85 
86  // Decrease the amont of memory in use accordingly
87  fInUse -= fChunkSize;
88 
89  // If the maximum memory has changed, we might be over the limit.
90  // In this case: free a slot
92  {
94  return;
95  }
96 
97  {
98  const std::lock_guard<std::mutex> lock(fMutexMem);
99  fMemoryStock.emplace_front(mem);
100  }
101 
102  {
103  const std::lock_guard<std::mutex> lock(fMutexCond);
104  fCond.notify_one();
105  }
106  }
std::mutex fMutexMem
Definition: MemoryManager.h:29
std::condition_variable fCond
Definition: MemoryManager.h:31
size_t fMaxMemory
Definition: MemoryManager.h:22
size_t fInUse
Definition: MemoryManager.h:24
std::forward_list< std::shared_ptr< char > > fMemoryStock
Definition: MemoryManager.h:33
size_t fAllocated
Definition: MemoryManager.h:25
size_t fChunkSize
Definition: MemoryManager.h:21
std::mutex fMutexCond
Definition: MemoryManager.h:30