Skip to content
Snippets Groups Projects
Commit 27b86547 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix locks for mutex debug mode

parent 975ec61a
Branches
Tags
No related merge requests found
Pipeline #19397 passed
...@@ -54,9 +54,12 @@ bool Reader::begin() { ...@@ -54,9 +54,12 @@ bool Reader::begin() {
}*/ }*/
bool Reader::read(int64_t ts, const std::function<void(const ftl::codecs::StreamPacket &, ftl::codecs::Packet &)> &f) { bool Reader::read(int64_t ts, const std::function<void(const ftl::codecs::StreamPacket &, ftl::codecs::Packet &)> &f) {
//UNIQUE_LOCK(mtx_, lk); #ifdef DEBUG_MUTEX
UNIQUE_LOCK(mtx_, lk);
#else
std::unique_lock<std::mutex> lk(mtx_, std::defer_lock); std::unique_lock<std::mutex> lk(mtx_, std::defer_lock);
if (!lk.try_lock()) return true; if (!lk.try_lock()) return true;
#endif
// Check buffer first for frames already read // Check buffer first for frames already read
for (auto i = data_.begin(); i != data_.end();) { for (auto i = data_.begin(); i != data_.end();) {
......
...@@ -65,9 +65,12 @@ bool File::tick(int64_t ts) { ...@@ -65,9 +65,12 @@ bool File::tick(int64_t ts) {
return false; return false;
} }
//UNIQUE_LOCK(mtx_, lk); #ifdef DEBUG_MUTEX
UNIQUE_LOCK(mutex_, lk);
#else
std::unique_lock<std::mutex> lk(mutex_, std::defer_lock); std::unique_lock<std::mutex> lk(mutex_, std::defer_lock);
if (!lk.try_lock()) return true; if (!lk.try_lock()) return true;
#endif
if (jobs_ > 0) { if (jobs_ > 0) {
//LOG(ERROR) << "STILL HAS JOBS"; //LOG(ERROR) << "STILL HAS JOBS";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment