Rosetta
|
#include <ArrayPool.hh>
Public Member Functions | |
ArrayPool () | |
Creation and destruction. More... | |
ArrayPool (platform::Size block_size) | |
Constructor with block-size specification. More... | |
ArrayPool (platform::Size block_size, platform::Size array_size) | |
Constructor with block-size and array-size specification. More... | |
~ArrayPool () override | |
platform::Size | array_size () const |
Methods to read information about the pool size. More... | |
platform::Size | block_size () const |
Returns the number of arrays to allocate in each block. More... | |
platform::Size | footprint () const |
Returns the number of bytes occupied by all allocated and not-yet allocated arrays. More... | |
void | set_array_size (platform::Size size) |
Methods to modify the size of the pool. More... | |
void | set_block_size (platform::Size size) |
platform::Size | nblocks () const |
Return the number of allocated array blocks. More... | |
platform::Size | nallocated () const |
Return the number of allocated arrays. If this were multiplied by the array_size_, then you'd have the amount of space spent representing the T arrays but you wouldn't have the amount of space spent representing the negative space linked list. More... | |
platform::Size | noutstanding () const |
Return the number of allocated arrays that have been requested by the user and are now "outstanding" in that they have to be returned before the array pool may be deleted. More... | |
bool | empty () const |
ArrayPoolElement< T > | new_array () |
Methods for allocating and deallocating arrays from this pool. More... | |
void | deallocate_array (ArrayPoolElement< T > const &element) |
Free an ArrayPoolElement to the pool. The element is invalid after this call completes. More... | |
![]() | |
VirtualBase ()=default | |
Default constructor. More... | |
virtual | ~VirtualBase ()=default |
The virtual destructor is one of the main reasons for the VirtualBase class. More... | |
VirtualBase (VirtualBase const &)=default | |
VirtualBase (VirtualBase &&)=default | |
VirtualBase & | operator= (VirtualBase const &)=default |
VirtualBase & | operator= (VirtualBase &&)=default |
Private Member Functions | |
void | create_new_block () |
Add a new block to the pool and add the elements of this block to the negative space singly linked list. The block sizes and the array sizes must be set before this method is called and, so long as the ArrayPool is not empty, these sizes may not be altered. More... | |
void | clear () |
Deallocate all the allocated blocks. The pool must be empty before this should be called or dangling references are likely. More... | |
bool | mine (NegSpaceElement< T > const *neg_element) const |
Determine if a given pointer to a negative-space element belongs to this pool. The compiler cannot ensure that when a ArrayPoolElement is handed to the deallocate_array method that it belongs to the pool being invoked upon. More... | |
Private Attributes | |
platform::Size | block_size_ |
platform::Size | array_size_ |
platform::Size | nblocks_ |
platform::Size | nnegative_ |
NegSpaceElement< T > | neg_begin_ |
std::list< NegSpaceElement< T > * > | neg_space_blocks_ |
std::list< T * > | array_blocks_ |
|
inline |
Creation and destruction.
Default constructor uses a block size of 32
|
inline |
Constructor with block-size specification.
|
inline |
Constructor with block-size and array-size specification.
|
inlineoverride |
|
inline |
Methods to read information about the pool size.
Returns the size of each array to be allocated.
References utility::graph::ArrayPool< T >::array_size_.
|
inline |
Returns the number of arrays to allocate in each block.
References utility::graph::ArrayPool< T >::block_size_.
|
inlineprivate |
Deallocate all the allocated blocks. The pool must be empty before this should be called or dangling references are likely.
References utility::graph::ArrayPool< T >::array_blocks_, debug_assert, utility::graph::ArrayPool< T >::empty(), basic::options::OptionKeys::in::file::list, utility::graph::ArrayPool< T >::nblocks_, utility::graph::ArrayPool< T >::neg_begin_, utility::graph::ArrayPool< T >::neg_space_blocks_, and utility::graph::ArrayPool< T >::nnegative_.
Referenced by pyrosetta.bindings.pose.ResidueLabelAccessor::discard(), utility::graph::ArrayPool< T >::set_array_size(), utility::graph::ArrayPool< T >::set_block_size(), and utility::graph::ArrayPool< T >::~ArrayPool().
|
inlineprivate |
Add a new block to the pool and add the elements of this block to the negative space singly linked list. The block sizes and the array sizes must be set before this method is called and, so long as the ArrayPool is not empty, these sizes may not be altered.
This array pool supports, but does not recommend using, array sizes of 0. The resulting ArrayPoolElements have Array0 objecst that point at null, and therefore, should never be dereferenced. However, there is nothing inherrently wrong with pointing at null, or with having an array that is never examined, and so it is supported.
References utility::graph::ArrayPool< T >::array_blocks_, utility::graph::ArrayPool< T >::array_size_, utility::graph::block_allocation_error_message(), utility::graph::ArrayPool< T >::block_size_, debug_assert, create_a3b_hbs::ii, utility::graph::ArrayPool< T >::nblocks_, utility::graph::ArrayPool< T >::neg_begin_, utility::graph::ArrayPool< T >::neg_space_blocks_, utility::graph::neg_space_element_allocation_error_message(), utility::graph::ArrayPool< T >::nnegative_, utility::graph::NegSpaceElement< T >::set_array(), utility::graph::NegSpaceElement< T >::set_next(), and utility_exit_with_message.
Referenced by utility::graph::ArrayPool< T >::new_array().
|
inline |
Free an ArrayPoolElement to the pool. The element is invalid after this call completes.
References utility::graph::NegSpaceElement< T >::allocated(), debug_assert, utility::graph::ArrayPool< T >::mine(), utility::graph::ArrayPool< T >::nallocated(), utility::graph::ArrayPool< T >::neg_begin_, utility::graph::ArrayPoolElement< T >::neg_ptr_, utility::graph::ArrayPool< T >::nnegative_, and utility::graph::NegSpaceElement< T >::set_allocated().
|
inline |
References utility::graph::ArrayPool< T >::nallocated(), and utility::graph::ArrayPool< T >::nnegative_.
Referenced by utility::graph::ArrayPool< T >::clear(), utility::graph::ArrayPool< T >::set_array_size(), utility::graph::ArrayPool< T >::set_block_size(), and utility::graph::ArrayPool< T >::~ArrayPool().
|
inline |
Returns the number of bytes occupied by all allocated and not-yet allocated arrays.
Approximate the cost of each list element in the two std::lists as 4 times the cost of a pointer.
References utility::graph::ArrayPool< T >::array_size_, utility::graph::ArrayPool< T >::block_size_, and utility::graph::ArrayPool< T >::nblocks_.
|
inlineprivate |
Determine if a given pointer to a negative-space element belongs to this pool. The compiler cannot ensure that when a ArrayPoolElement is handed to the deallocate_array method that it belongs to the pool being invoked upon.
This method is too slow to include in release builds, but is here to ensure in debug mode that two pools don't accidentally start crossing their pointers and "sharing" data, since that would be disasterous.
References utility::graph::ArrayPool< T >::block_size_, basic::options::OptionKeys::in::file::list, and utility::graph::ArrayPool< T >::neg_space_blocks_.
Referenced by utility::graph::ArrayPool< T >::deallocate_array().
|
inline |
Return the number of allocated arrays. If this were multiplied by the array_size_, then you'd have the amount of space spent representing the T arrays but you wouldn't have the amount of space spent representing the negative space linked list.
References utility::graph::ArrayPool< T >::block_size_, and utility::graph::ArrayPool< T >::nblocks_.
Referenced by utility::graph::ArrayPool< T >::deallocate_array(), utility::graph::ArrayPool< T >::empty(), and utility::graph::ArrayPool< T >::noutstanding().
|
inline |
Return the number of allocated array blocks.
References utility::graph::ArrayPool< T >::nblocks_.
|
inline |
Methods for allocating and deallocating arrays from this pool.
Request a new ArrayPoolElement from the pool. This method will enlarge the pool if it has grown to its capacity.
References utility::graph::ArrayPool< T >::array_size_, utility::graph::ArrayPool< T >::create_new_block(), debug_assert, create_a3b_hbs::first, utility::graph::ArrayPool< T >::neg_begin_, and utility::graph::ArrayPool< T >::nnegative_.
|
inline |
Return the number of allocated arrays that have been requested by the user and are now "outstanding" in that they have to be returned before the array pool may be deleted.
References utility::graph::ArrayPool< T >::nallocated(), and utility::graph::ArrayPool< T >::nnegative_.
|
inline |
Methods to modify the size of the pool.
Set the size of the arrays that the pool is meant to allocate.
The
References utility::graph::ArrayPool< T >::array_size_, utility::graph::ArrayPool< T >::clear(), utility::graph::ArrayPool< T >::empty(), subloop_histogram::size, and utility_exit_with_message.
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |