From bab94513cbc85b12a0c921ec44aa8727c91a07a4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Sep 2023 20:53:43 +0200 Subject: [PATCH] Cleanup: coding style. --- src/lib/grok/messenger.h | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/lib/grok/messenger.h b/src/lib/grok/messenger.h index 5cb21a1cd..50d44e251 100644 --- a/src/lib/grok/messenger.h +++ b/src/lib/grok/messenger.h @@ -461,7 +461,7 @@ static void processorThread(Messenger* messenger, std::function lk(shutdownMutex_); - initialized_ = true; + _initialized = true; clientInitializedCondition_.notify_all(); } - bool waitForClientInit(void) + + bool waitForClientInit() { - if(initialized_) + if (_initialized) { return true; + } std::unique_lock lk(shutdownMutex_); - if(initialized_) + + if (_initialized) { return true; - else if (shutdown_) + } else if (_shutdown) { return false; - clientInitializedCondition_.wait(lk, [this]{return initialized_ || shutdown_;}); + } + + clientInitializedCondition_.wait(lk, [this] { return _initialized || _shutdown; }); - return initialized_ && !shutdown_; + return _initialized && !_shutdown; } + static size_t uncompressedFrameSize(uint32_t w, uint32_t h, uint32_t samplesPerPixel) { return sizeof(uint16_t) * w * h * samplesPerPixel; @@ -637,8 +643,8 @@ struct Messenger return (uint8_t*)(compressed_buffer_ + frameId * init_.compressedFrameSize_); } std::atomic_bool running; - bool initialized_; - bool shutdown_; + bool _initialized; + bool _shutdown; MessengerBlockingQueue sendQueue; MessengerBlockingQueue receiveQueue; MessengerBlockingQueue availableBuffers_; @@ -754,11 +760,11 @@ struct Msg }; static void processorThread(Messenger* messenger, std::function processor) { - while(messenger->running) - { + while (messenger->running) { std::string message; - if(!messenger->receiveQueue.waitAndPop(message)) + if (!messenger->receiveQueue.waitAndPop(message)) { break; + } if(!messenger->running) break; Msg msg(message); @@ -856,7 +862,7 @@ struct ScheduledMessenger : public Messenger } ++framesCompressed_; send(GRK_MSGR_BATCH_PROCESSSED_COMPRESSED, compressedFrameId); - if (shutdown_ && framesCompressed_ == framesScheduled_) + if (_shutdown && framesCompressed_ == framesScheduled_) shutdownCondition_.notify_all(); } void shutdown(void){ @@ -864,7 +870,7 @@ struct ScheduledMessenger : public Messenger std::unique_lock lk(shutdownMutex_); if (!async_result_.valid()) return; - shutdown_ = true; + _shutdown = true; if (framesScheduled_) { uint32_t scheduled = framesScheduled_; send(GRK_MSGR_BATCH_FLUSH, scheduled); -- 2.30.2