Added memory pool logging
[platform/core/uifw/dali-core.git] / dali / internal / common / fixed-size-memory-pool.h
index a3317ed..6e05ffe 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H__
-#define __DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H__
+#ifndef DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H
+#define DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * 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.
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 /**
  * @brief Calculate the size of a type taking alignment into account
  */
-template< typename T >
+template<typename T>
 struct TypeSizeWithAlignment
 {
   ///< The size of the type with alignment taken into account
-  static const size_t size = ( ( sizeof( T ) + sizeof( void* ) - 1 ) / sizeof( void* ) ) * sizeof( void* );
+  static const size_t size = ((sizeof(T) + sizeof(void*) - 1) / sizeof(void*)) * sizeof(void*);
 };
 
 /**
@@ -52,11 +50,9 @@ struct TypeSizeWithAlignment
 class FixedSizeMemoryPool
 {
 public:
-
-  typedef uint32_t SizeType;
+  using SizeType = uint32_t;
 
 public:
-
   /**
    * @brief Constructor.
    *
@@ -66,7 +62,7 @@ public:
    * @param maximumBlockCapacity The maximum size that a new block of memory can be allocated. Defaults to
    *                             a large value (1024 * 1024 = 1048576).
    */
-  explicit FixedSizeMemoryPool( SizeType fixedSize, SizeType initialCapacity = 32, SizeType maximumBlockCapacity = 1048576 );
+  explicit FixedSizeMemoryPool(SizeType fixedSize, SizeType initialCapacity = 32, SizeType maximumBlockCapacity = 1048576);
 
   /**
    * @brief Destructor.
@@ -92,32 +88,36 @@ public:
    *
    * @param memory The memory to be deleted. Must have been allocated by this memory pool
    */
-  void Free( void* memory );
+  void Free(void* memory);
 
   /**
    * @brief Thread-safe version of Free()
    *
    * @param memory The memory to be deleted. Must have been allocated by this memory pool
    */
-  void FreeThreadSafe( void* memory );
+  void FreeThreadSafe(void* memory);
 
-private:
+  /**
+   * Get the current capacity of the memory pool
+   *
+   * @note in release mode, this returns 0, as the block size isn't defined.
+   */
+  uint32_t GetCapacity() const;
 
+private:
   // Undefined
-  FixedSizeMemoryPool( const FixedSizeMemoryPool& fixedSizeMemoryPool );
+  FixedSizeMemoryPool(const FixedSizeMemoryPool& fixedSizeMemoryPool);
 
   // Undefined
-  FixedSizeMemoryPool& operator=( const FixedSizeMemoryPool& fixedSizeMemoryPool );
+  FixedSizeMemoryPool& operator=(const FixedSizeMemoryPool& fixedSizeMemoryPool);
 
 private:
-
   struct Impl;
   Impl* mImpl;
-
 };
 
 } // namespace Internal
 
 } // namespace Dali
 
-#endif /* __DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H__ */
+#endif // DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H