add explicit to LockedPacket constructor

This commit is contained in:
Isaac Connor 2021-04-17 11:35:18 -04:00
parent 5ace2ca082
commit 96deedfd53
1 changed files with 3 additions and 2 deletions

View File

@ -80,7 +80,7 @@ class ZMLockedPacket {
std::unique_lock<std::mutex> lck_;
bool locked;
ZMLockedPacket(ZMPacket *p) :
explicit ZMLockedPacket(ZMPacket *p) :
packet_(p),
lck_(packet_->mutex_, std::defer_lock),
locked(false) {
@ -95,11 +95,13 @@ class ZMLockedPacket {
locked = true;
Debug(4, "packet %d locked", packet_->image_index);
};
bool trylock() {
Debug(4, "TryLocking packet %d", packet_->image_index);
locked = lck_.try_lock();
return locked;
};
void unlock() {
Debug(4, "packet %d unlocked", packet_->image_index);
locked = false;
@ -109,7 +111,6 @@ class ZMLockedPacket {
void wait() {
Debug(4, "packet %d waiting", packet_->image_index);
// We already have a lock, but it's a recursive mutex.. so this may be ok
packet_->condition_.wait(lck_);
}
};