Get the smallest frame number (or NULL shared_ptr if no frame is found)
| 242 | |
| 243 | // Get the smallest frame number (or NULL shared_ptr if no frame is found) |
| 244 | std::shared_ptr<Frame> CacheDisk::GetSmallestFrame() |
| 245 | { |
| 246 | // Create a scoped lock, to protect the cache from multiple threads |
| 247 | const std::lock_guard<std::recursive_mutex> lock(*cacheMutex); |
| 248 | |
| 249 | // Loop through frame numbers |
| 250 | std::deque<int64_t>::iterator itr; |
| 251 | int64_t smallest_frame = -1; |
| 252 | for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr) |
| 253 | { |
| 254 | if (*itr < smallest_frame || smallest_frame == -1) |
| 255 | smallest_frame = *itr; |
| 256 | } |
| 257 | |
| 258 | // Return frame (if any) |
| 259 | if (smallest_frame != -1) { |
| 260 | return GetFrame(smallest_frame); |
| 261 | } else { |
| 262 | return NULL; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | // Gets the maximum bytes value |
| 267 | int64_t CacheDisk::GetBytes() |