Dali 3D User Interface Engine
fixed-size-memory-pool.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H__
2 #define __DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H__
3 
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 
21 // EXTERNAL INCLUDES
22 #include <stdint.h>
23 #include <cstddef>
24 
25 namespace Dali
26 {
27 
28 namespace Internal
29 {
30 
34 template< typename T >
36 {
38  static const size_t size = ( ( sizeof( T ) + sizeof( void* ) - 1 ) / sizeof( void* ) ) * sizeof( void* );
39 };
40 
53 {
54 public:
55 
56  typedef uint32_t SizeType;
57 
58 public:
59 
69  explicit FixedSizeMemoryPool( SizeType fixedSize, SizeType initialCapacity = 32, SizeType maximumBlockCapacity = 1048576 );
70 
75 
81  void* Allocate();
82 
88  void* AllocateThreadSafe();
89 
95  void Free( void* memory );
96 
102  void FreeThreadSafe( void* memory );
103 
104 private:
105 
106  // Undefined
107  FixedSizeMemoryPool( const FixedSizeMemoryPool& fixedSizeMemoryPool );
108 
109  // Undefined
110  FixedSizeMemoryPool& operator=( const FixedSizeMemoryPool& fixedSizeMemoryPool );
111 
112 private:
113 
114  struct Impl;
115  Impl* mImpl;
116 
117 };
118 
119 } // namespace Internal
120 
121 } // namespace Dali
122 
123 #endif /* __DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H__ */
Dali Docs Home
Read more about Dali