mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-30 11:02:19 +08:00
CameraBuf::acquire : using a scoped lock (#19764)
* Using a scoped lock * Trigger Build old-commit-hash: 20726997199aedea1ee40e6891a450ae70d56717
This commit is contained in:
@@ -121,14 +121,14 @@ CameraBuf::~CameraBuf() {
|
||||
}
|
||||
|
||||
bool CameraBuf::acquire() {
|
||||
std::unique_lock<std::mutex> lk(frame_queue_mutex);
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(frame_queue_mutex);
|
||||
bool got_frame = frame_queue_cv.wait_for(lk, std::chrono::milliseconds(1), [this]{ return !frame_queue.empty(); });
|
||||
if (!got_frame) return false;
|
||||
|
||||
bool got_frame = frame_queue_cv.wait_for(lk, std::chrono::milliseconds(1), [this]{ return !frame_queue.empty(); });
|
||||
if (!got_frame) return false;
|
||||
|
||||
cur_buf_idx = frame_queue.front();
|
||||
frame_queue.pop();
|
||||
lk.unlock();
|
||||
cur_buf_idx = frame_queue.front();
|
||||
frame_queue.pop();
|
||||
}
|
||||
|
||||
const FrameMetadata &frame_data = camera_bufs_metadata[cur_buf_idx];
|
||||
if (frame_data.frame_id == -1) {
|
||||
|
||||
Reference in New Issue
Block a user