docs/Writerside/topics/mempool.h.md

changeset 1694
a2757c6427cc
parent 1654
5ab3fe0b7859
child 1696
976e629ce990
equal deleted inserted replaced
1693:c2d05cf1a062 1694:a2757c6427cc
116 116
117 Memory managed by a pool can be transferred to another pool. 117 Memory managed by a pool can be transferred to another pool.
118 118
119 The function `cxMempoolTransfer()` transfers all memory managed and/or registered with the `source` pool to the `dest` pool. 119 The function `cxMempoolTransfer()` transfers all memory managed and/or registered with the `source` pool to the `dest` pool.
120 It also registers its allocator with the `dest` pool and creates a new allocator for the `source` pool. 120 It also registers its allocator with the `dest` pool and creates a new allocator for the `source` pool.
121 That means, that all references to the allocator of the `source` pool remain valid and continue to work with the `dest` pool. 121 That means that all references to the allocator of the `source` pool remain valid and continue to work with the `dest` pool.
122 The transferred allocator will be destroyed when the `dest` pool gets destroyed. 122 The transferred allocator will be destroyed when the `dest` pool gets destroyed.
123 123
124 The function `cxMempoolTransferObject()` transfers a _single_ object managed by the `source` pool to the `dest` pool. 124 The function `cxMempoolTransferObject()` transfers a _single_ object managed by the `source` pool to the `dest` pool.
125 In contrast to transferring an entire pool, if `obj` has a reference to `source->allocator`, it must be updated to `dest->allocator` manually. 125 In contrast to transferring an entire pool, if `obj` has a reference to `source->allocator`, it must be updated to `dest->allocator` manually.
126 It is also possible to transfer registered memory from one pool to another, this way. 126 It is also possible to transfer registered memory from one pool to another, this way.
129 - a necessary memory allocation was not possible 129 - a necessary memory allocation was not possible
130 - the `source` and `dest` pointers point to the same pool 130 - the `source` and `dest` pointers point to the same pool
131 - the pools have a different type (simple, advanced, pure) 131 - the pools have a different type (simple, advanced, pure)
132 - the pools have different base allocators (i.e. `cxDefaultAllocator` changed between creation of the pools) 132 - the pools have different base allocators (i.e. `cxDefaultAllocator` changed between creation of the pools)
133 133
134 In case of an error, no memory is transferred and both pools remain unchanged and are in a valid state. 134 In case of an error, no memory is transferred, and both pools remain unchanged and are in a valid state.
135 135
136 136
137 ## Example 137 ## Example
138 138
139 The following code illustrates how the contents of a CSV file are read into pooled memory. 139 The following code illustrates how the contents of a CSV file are read into pooled memory.

mercurial