Add a Frame to the cache
| 45 | |
| 46 | // Add a Frame to the cache |
| 47 | void CacheMemory::Add(std::shared_ptr<Frame> frame) |
| 48 | { |
| 49 | // Create a scoped lock, to protect the cache from multiple threads |
| 50 | const std::lock_guard<std::recursive_mutex> lock(*cacheMutex); |
| 51 | int64_t frame_number = frame->number; |
| 52 | |
| 53 | // Freshen frame if it already exists |
| 54 | if (frames.count(frame_number)) |
| 55 | // Move frame to front of queue |
| 56 | Touch(frame_number); |
| 57 | |
| 58 | else |
| 59 | { |
| 60 | // Add frame to queue and map |
| 61 | frames[frame_number] = frame; |
| 62 | frame_numbers.push_front(frame_number); |
| 63 | ordered_frame_numbers.push_back(frame_number); |
| 64 | needs_range_processing = true; |
| 65 | |
| 66 | // Clean up old frames |
| 67 | CleanUp(); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // Check if frame is already contained in cache |
| 72 | bool CacheMemory::Contains(int64_t frame_number) { |
nothing calls this directly
no outgoing calls
no test coverage detected