diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-09-26 20:53:43 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-12-16 02:07:38 +0100 |
| commit | 88163c57447042c71ed8c546b16bb225836b410b (patch) | |
| tree | 9f544306571fbeb945be1ad6eb5ecb4c765e25eb | |
| parent | 81442e6a2302aa24a482267c1441b5bee3a3eac2 (diff) | |
Cleanup: coding style.
| -rw-r--r-- | src/lib/grok/messenger.h | 36 |
1 files 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<void(std::string struct Messenger { explicit Messenger(MessengerInit init) - : running(true), initialized_(false), shutdown_(false), init_(init), + : running(true), _initialized(false), _shutdown(false), init_(init), outboundSynch_(nullptr), inboundSynch_(nullptr), uncompressed_buffer_(nullptr), compressed_buffer_(nullptr), uncompressed_fd_(0), compressed_fd_(0) @@ -591,23 +591,29 @@ struct Messenger } std::unique_lock<std::mutex> lk(shutdownMutex_); - initialized_ = true; + _initialized = true; clientInitializedCondition_.notify_all(); } - bool waitForClientInit(void) + + bool waitForClientInit() { - if(initialized_) + if (_initialized) { return true; + } std::unique_lock<std::mutex> 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<std::string> sendQueue; MessengerBlockingQueue<std::string> receiveQueue; MessengerBlockingQueue<BufferSrc> availableBuffers_; @@ -754,11 +760,11 @@ struct Msg }; static void processorThread(Messenger* messenger, std::function<void(std::string)> 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<std::mutex> lk(shutdownMutex_); if (!async_result_.valid()) return; - shutdown_ = true; + _shutdown = true; if (framesScheduled_) { uint32_t scheduled = framesScheduled_; send(GRK_MSGR_BATCH_FLUSH, scheduled); |
