Added memory pool logging
[platform/core/uifw/dali-core.git] / dali / internal / update / queue / update-message-queue.h
index 322e1d0..cfc47ba 100644 (file)
@@ -1,30 +1,32 @@
-#ifndef __DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H__
-#define __DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H__
-
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+#ifndef DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H
+#define DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H
+
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // INTERNAL INCLUDES
 #include <dali/internal/common/buffer-index.h>
-#include <dali/internal/common/event-to-update.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
 
+// EXTERNAL INCLUDES
+#include <cstddef>
+
 namespace Dali
 {
-
 namespace Integration
 {
 class RenderController;
@@ -32,61 +34,61 @@ class RenderController;
 
 namespace Internal
 {
-
 class MessageBase;
 
-namespace Update
+namespace SceneGraph
 {
+class SceneGraphBuffers;
+}
 
+namespace Update
+{
 /**
  * Used by UpdateManager to receive messages from the event-thread.
- * The event-thread uses the EventToUpdate interface to queue messages for the next update.
  */
-class MessageQueue: public EventToUpdate
+class MessageQueue
 {
 public:
-
   /**
    * Create a new UpdateMessageQueue.
    * @param[in] renderController After messages are flushed, we request a render from the RenderController.
    * @param[in] sceneGraphBuffers Used to keep track of which buffers are being written or read.
    */
-  MessageQueue( Integration::RenderController& renderController,
-                const SceneGraph::SceneGraphBuffers& sceneGraphBuffers );
+  MessageQueue(Integration::RenderController&       renderController,
+               const SceneGraph::SceneGraphBuffers& sceneGraphBuffers);
 
   /**
-   * Virtual destructor
+   * Destructor
    */
-  virtual ~MessageQueue();
-
-  // From EventToUpdate interface
+  ~MessageQueue();
 
   /**
-   * @copydoc Dali::Internal::EventToUpdate::EventProcessingStarted()
+   * Inform the queue that event processing has started
    */
-  virtual void EventProcessingStarted();
+  void EventProcessingStarted();
 
   /**
-   * @copydoc Dali::Internal::EventToUpdate::ReserveMessageSlot()
+   * Reserve space for a message
+   * @param[in] size the message size with respect to the size of type 'char'
+   * @param[in] updateScene If set to true, denotes that the message will cause the scene graph node tree to require an update
+   * @return A pointer to the first char allocated for the message
    */
-  virtual unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene );
+  uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene);
 
   /**
-   * @copydoc Dali::Internal::EventToUpdate::GetEventBufferIndex()
+   * Flushes the message queue
+   * @return true if there are messages to process
    */
-  virtual BufferIndex GetEventBufferIndex() const;
-
-  /**
-   * @copydoc Dali::Internal::EventToUpdate::FlushQueue()
-   */
-  virtual bool FlushQueue();
+  bool FlushQueue();
 
   // Exclusive to UpdateManager
 
   /**
    * Called once per update; process the previously flushed messages.
+   * @param updateBufferIndex to use
+   * @return true if the scene graph node tree is updated
    */
-  void ProcessMessages();
+  bool ProcessMessages(BufferIndex updateBufferIndex);
 
   /**
    * Query whether the queue was empty this frame.
@@ -100,16 +102,25 @@ public:
    */
   bool IsSceneUpdateRequired() const;
 
-private:
+  /**
+   * Query for the capacity of the current message queue
+   */
+  std::size_t GetCapacity() const;
 
+private:
   /**
    * Helper to call Process and destructor on each queued message
    * @param[in] minorQueue The queue to process.
    */
-  void ProcessMinorQueue( char* minorQueue );
+  void ProcessMinorQueue(char* minorQueue);
 
 private:
+  // Not copyable:
+  MessageQueue()                                   = delete;
+  MessageQueue(const MessageQueue& rhs)            = delete;
+  MessageQueue& operator=(const MessageQueue& rhs) = delete;
 
+private:
   struct Impl;
   Impl* mImpl;
 };
@@ -120,4 +131,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H__
+#endif // DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H