25 #ifndef TERVEL_MEMORY_RC_DESCRIPTOR_POOL_H_
26 #define TERVEL_MEMORY_RC_DESCRIPTOR_POOL_H_
83 template<
typename DescrType,
typename... Args>
211 template<
typename DescrType,
typename... Args>
214 if (elem ==
nullptr) {
218 DescrType * descr =
reinterpret_cast<DescrType *
>(elem->
descriptor());
228 #endif // TERVEL_MEMORY_RC_DESCRIPTOR_POOL_H_
uint64_t safe_pool_count_
Two counters used to track the number of elements in the linked list.
Definition: descriptor_pool.h:202
A manager class for the reference count protected memory pools.
Definition: pool_manager.h:54
Descriptor * descriptor()
Returns a pointer to the associated descriptor of this element.
Definition: pool_element.h:83
TODO(steven):
Definition: mcas.h:36
uint64_t unsafe_pool_count_
Definition: descriptor_pool.h:203
PoolElement * unsafe_pool_
A linked list of pool elements.
Definition: descriptor_pool.h:196
uint64_t pool_id_
The pool where excess elements are placed.
Definition: descriptor_pool.h:180
void free_descriptor(tervel::util::Descriptor *descr, bool dont_check=false)
Once a user is done with a descriptor, they should free it with this method.
bool verify_pool_count(PoolElement *pool, uint64_t count)
verifies that the length of the linked list matches the count
void send_unsafe_to_manager()
Sends the elements from the unsafe pool to the corresponding unsafe pool in this pool's manager...
PoolElement * get_from_pool(bool allocate_new=true)
Gets a free element.
PoolElement * safe_pool_
A linked list of pool elements.
Definition: descriptor_pool.h:188
DescriptorPool(PoolManager *manager, uint64_t pool_id, int prefill=TERVEL_MEM_RC_MIN_NODES)
Definition: descriptor_pool.h:59
This defines the Descriptor class, this class is designed to be extend and be used in conjunction wit...
Definition: descriptor.h:60
void reserve(size_t num_descriptors=TERVEL_MEM_RC_MIN_NODES)
Allocates an extra num_descriptors elements to the pool.
DISALLOW_COPY_AND_ASSIGN(DescriptorPool)
#define TERVEL_MEM_RC_MIN_NODES
Definition: util.h:80
void offload()
Sends a subset of the elements to the managers pool.
This class is used to hold the memory management information (Header) and a descriptor object...
Definition: pool_element.h:46
DescrType * get_descriptor(Args &&...args)
Constructs and returns a descriptor.
Definition: descriptor_pool.h:212
void init_descriptor(Args &&...args)
Constructs a descriptor of the given type within this pool element.
Definition: pool_element.h:147
void add_to_unsafe(tervel::util::Descriptor *descr)
Releases the descriptor back to the unsafe pool.
PoolManager * manager_
This pool's manager.
Definition: descriptor_pool.h:175
Defines a pool of descriptor objects which is used to allocate descriptors and to store them while th...
Definition: descriptor_pool.h:57
~DescriptorPool()
Definition: descriptor_pool.h:68
void add_to_safe(tervel::util::Descriptor *descr)
Releases the descriptor back to the safe pool.
void try_clear_unsafe_pool(bool dont_check=false)
Try to move elements from the unsafe pool to the safe pool.
void send_safe_to_manager()
Sends the elements from the safe pool to the corresponding safe pool in this pool's manager...