Commit db969583 by Christian Kern

implementation for jira ticket #520

parent a74b7bac
......@@ -269,6 +269,14 @@ LockFreeTreeValuePool<Type, Undefined, PoolAllocator, TreeAllocator>::
}
}
template<typename Type, Type Undefined, class PoolAllocator,
class TreeAllocator >
size_t LockFreeTreeValuePool<Type, Undefined, PoolAllocator, TreeAllocator>::
GetMinimumElementCountForGuaranteedCapacity(size_t capacity) {
// for this value pool, this is just capacity...
return capacity;
}
} // namespace containers
} // namespace embb
......
......@@ -117,8 +117,9 @@ size_t ObjectPool<Type, ValuePool, ObjectAllocator>::GetCapacity() {
template<class Type, typename ValuePool, class ObjectAllocator>
ObjectPool<Type, ValuePool, ObjectAllocator>::ObjectPool(size_t capacity) :
capacity(capacity),
p(ReturningTrueIterator(0), ReturningTrueIterator(capacity)) {
capacity(capacity),
p(ReturningTrueIterator(0), ReturningTrueIterator(
ValuePool::GetMinimumElementCountForGuaranteedCapacity(capacity))) {
// Allocate the objects (without construction, just get the memory)
objects = objectAllocator.allocate(capacity);
}
......
......@@ -95,6 +95,14 @@ WaitFreeArrayValuePool<Type, Undefined, Allocator>::~WaitFreeArrayValuePool() {
// free memory
allocator.deallocate(pool, static_cast<size_t>(size));
}
template<typename Type, Type Undefined, class Allocator >
size_t WaitFreeArrayValuePool<Type, Undefined, Allocator>::
GetMinimumElementCountForGuaranteedCapacity(size_t capacity) {
// for this value pool, this is just capacity...
return capacity;
}
} // namespace containers
} // namespace embb
......
......@@ -278,6 +278,14 @@ class LockFreeTreeValuePool {
);
/**
* Due to concurrency effects, a pool might provide less elements than managed
* by it. However, usually one wants to guarantee a minimal capacity. The
* count of elements, that must be given to the pool when to guarantee \c
* capacity elements is computed using this function.
*/
static size_t GetMinimumElementCountForGuaranteedCapacity(size_t capacity);
/**
* Destructs the pool.
*
* \notthreadsafe
......
......@@ -150,6 +150,14 @@ class WaitFreeArrayValuePool {
);
/**
* Due to concurrency effects, a pool might provide less elements than managed
* by it. However, usually one wants to guarantee a minimal capacity. The
* count of elements, that must be given to the pool when to guarantee \c
* capacity elements is computed using this function.
*/
static size_t GetMinimumElementCountForGuaranteedCapacity(size_t capacity);
/**
* Destructs the pool.
*
* \notthreadsafe
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment