Move frame to front of queue (so it lasts longer)
| 196 | |
| 197 | // Move frame to front of queue (so it lasts longer) |
| 198 | void CacheMemory::Touch(int64_t frame_number) |
| 199 | { |
| 200 | // Create a scoped lock, to protect the cache from multiple threads |
| 201 | const std::lock_guard<std::recursive_mutex> lock(*cacheMutex); |
| 202 | |
| 203 | // Does frame exists in cache? |
| 204 | if (frames.count(frame_number)) |
| 205 | { |
| 206 | // Loop through frame numbers |
| 207 | std::deque<int64_t>::iterator itr; |
| 208 | for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr) |
| 209 | { |
| 210 | if (*itr == frame_number) |
| 211 | { |
| 212 | // erase frame number |
| 213 | frame_numbers.erase(itr); |
| 214 | |
| 215 | // add frame number to 'front' of queue |
| 216 | frame_numbers.push_front(frame_number); |
| 217 | break; |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | // Clear the cache of all frames |
| 224 | void CacheMemory::Clear() |
nothing calls this directly
no outgoing calls
no test coverage detected