renderer_opengl: Use more concise lock syntax.

This commit is contained in:
bunnei 2020-02-26 18:35:35 -05:00
parent aef159354c
commit a17214baea
1 changed files with 4 additions and 4 deletions

View File

@ -65,7 +65,7 @@ public:
~FrameMailbox() { ~FrameMailbox() {
// lock the mutex and clear out the present and free_queues and notify any people who are // lock the mutex and clear out the present and free_queues and notify any people who are
// blocked to prevent deadlock on shutdown // blocked to prevent deadlock on shutdown
std::scoped_lock lock(swap_chain_lock); std::scoped_lock lock{swap_chain_lock};
std::queue<Frame*>().swap(free_queue); std::queue<Frame*>().swap(free_queue);
present_queue.clear(); present_queue.clear();
present_cv.notify_all(); present_cv.notify_all();
@ -115,7 +115,7 @@ public:
} }
Frame* GetRenderFrame() { Frame* GetRenderFrame() {
std::unique_lock<std::mutex> lock(swap_chain_lock); std::unique_lock lock{swap_chain_lock};
// If theres no free frames, we will reuse the oldest render frame // If theres no free frames, we will reuse the oldest render frame
if (free_queue.empty()) { if (free_queue.empty()) {
@ -130,13 +130,13 @@ public:
} }
void ReleaseRenderFrame(Frame* frame) { void ReleaseRenderFrame(Frame* frame) {
std::unique_lock<std::mutex> lock(swap_chain_lock); std::unique_lock lock{swap_chain_lock};
present_queue.push_front(frame); present_queue.push_front(frame);
present_cv.notify_one(); present_cv.notify_one();
} }
Frame* TryGetPresentFrame(int timeout_ms) { Frame* TryGetPresentFrame(int timeout_ms) {
std::unique_lock<std::mutex> lock(swap_chain_lock); std::unique_lock lock{swap_chain_lock};
// wait for new entries in the present_queue // wait for new entries in the present_queue
present_cv.wait_for(lock, std::chrono::milliseconds(timeout_ms), present_cv.wait_for(lock, std::chrono::milliseconds(timeout_ms),
[&] { return !present_queue.empty(); }); [&] { return !present_queue.empty(); });