MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / Add

Method Add

src/CacheMemory.cpp:47–69  ·  view source on GitHub ↗

Add a Frame to the cache

Source from the content-addressed store, hash-verified

45
46// Add a Frame to the cache
47void 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
72bool CacheMemory::Contains(int64_t frame_number) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected