From: Eunki Hong Date: Wed, 21 Dec 2022 12:03:26 +0000 (+0900) Subject: Do not block during process message queue X-Git-Tag: dali_2.2.7~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F61%2F285861%2F4;p=platform%2Fcore%2Fuifw%2Fdali-core.git Do not block during process message queue We don't need to block update thread during whole message Process works. Follow as NotificationManager::ProcessMessages() Change-Id: I04549bcd91f426d5c98dc159a01f0ec7be950f5f Signed-off-by: Eunki Hong --- diff --git a/dali/internal/update/queue/update-message-queue.cpp b/dali/internal/update/queue/update-message-queue.cpp index 8b80412..ba391b0 100644 --- a/dali/internal/update/queue/update-message-queue.cpp +++ b/dali/internal/update/queue/update-message-queue.cpp @@ -243,17 +243,27 @@ bool MessageQueue::ProcessMessages(BufferIndex updateBufferIndex) { PERF_MONITOR_START(PerformanceMonitor::PROCESS_MESSAGES); - // queueMutex must be locked whilst accessing queue - MessageQueueMutex::ScopedLock lock(mImpl->queueMutex); - - const MessageBufferIter processQueueEndIter = mImpl->processQueue.end(); - for(MessageBufferIter iter = mImpl->processQueue.begin(); iter != processQueueEndIter; ++iter) + MessageBufferQueue copiedProcessQueue; + bool sceneUpdated = false; { - MessageBuffer* buffer = *iter; + // queueMutex must be locked whilst accessing queue + MessageQueueMutex::ScopedLock lock(mImpl->queueMutex); + copiedProcessQueue = mImpl->processQueue; - for(MessageBuffer::Iterator iter = buffer->Begin(); iter.IsValid(); iter.Next()) + mImpl->sceneUpdate >>= 1; + + sceneUpdated = (mImpl->sceneUpdate & 0x01); // if it was previously 2, scene graph was updated. + + mImpl->queueWasEmpty = mImpl->processQueue.empty(); // Flag whether we processed anything + + mImpl->processQueue.clear(); + } + + for(auto&& buffer : copiedProcessQueue) + { + for(MessageBuffer::Iterator bufferIter = buffer->Begin(); bufferIter.IsValid(); bufferIter.Next()) { - MessageBase* message = reinterpret_cast(iter.Get()); + MessageBase* message = reinterpret_cast(bufferIter.Get()); message->Process(updateBufferIndex); @@ -261,20 +271,19 @@ bool MessageQueue::ProcessMessages(BufferIndex updateBufferIndex) message->~MessageBase(); } buffer->Reset(); - - // Pass back for use in the event-thread - mImpl->recycleQueue.push_back(buffer); } - mImpl->sceneUpdate >>= 1; - - mImpl->queueWasEmpty = mImpl->processQueue.empty(); // Flag whether we processed anything - - mImpl->processQueue.clear(); + // Pass back for use in the event-thread + { + MessageQueueMutex::ScopedLock lock(mImpl->queueMutex); + mImpl->recycleQueue.insert(mImpl->recycleQueue.end(), + std::make_move_iterator(copiedProcessQueue.begin()), + std::make_move_iterator(copiedProcessQueue.end())); + } PERF_MONITOR_END(PerformanceMonitor::PROCESS_MESSAGES); - return (mImpl->sceneUpdate & 0x01); // if it was previously 2, scene graph was updated. + return sceneUpdated; } bool MessageQueue::WasEmpty() const