Gromacs
2024.4
|
Private implementation class for AnalysisDataStorage.
Public Types | |
typedef std::unique_ptr < AnalysisDataStorageFrameData > | FramePointer |
Smart pointer type for managing a stored frame. | |
typedef std::vector< FramePointer > | FrameList |
Shorthand for a list of data frames that are currently stored. | |
typedef std::vector < AnalysisDataFrameBuilderPointer > | FrameBuilderList |
Shorthand for a list of currently unused storage frame builders. | |
Public Member Functions | |
bool | isMultipoint () const |
Returns whether the storage is set to use multipoint data. | |
bool | storeAll () const |
Whether storage of all frames has been requested. More... | |
int | firstStoredIndex () const |
Returns the index of the oldest frame that may be currently stored. | |
int | firstUnnotifiedIndex () const |
Returns the index of the first frame that is not fully notified. | |
int | computeStorageLocation (int index) const |
Computes index into frames_ for accessing frame index . More... | |
size_t | endStorageLocation () const |
Computes an index into frames_ that is one past the last frame stored. More... | |
void | extendBuffer (size_t newSize) |
Extends frames_ to a new size. More... | |
void | rotateBuffer () |
Remove oldest frame from the storage to make space for a new one. More... | |
AnalysisDataFrameBuilderPointer | getFrameBuilder () |
Returns a frame builder object for use with a new frame. More... | |
bool | shouldNotifyImmediately () const |
Returns whether notifications should be immediately fired. More... | |
bool | needStorage () const |
Returns whether data needs to be stored at all. More... | |
void | finishFrame (int index) |
Implementation for AnalysisDataStorage::finishFrame(). | |
void | finishFrameSerial (int index) |
Implementation for AnalysisDataStorage::finishFrameSerial(). | |
Public Attributes | |
const AbstractAnalysisData * | data_ |
Parent data object to access data dimensionality etc. | |
AnalysisDataModuleManager * | modules_ |
Manager to use for notification calls. | |
int | storageLimit_ |
Number of past frames that need to be stored. More... | |
int | pendingLimit_ |
Number of future frames that may need to be started. More... | |
FrameList | frames_ |
Data frames that are currently stored. More... | |
size_t | firstFrameLocation_ |
Location of oldest frame in frames_. | |
int | firstUnnotifiedIndex_ |
Index of the first frame that is not fully notified. | |
FrameBuilderList | builders_ |
Currently unused frame builders. More... | |
int | nextIndex_ |
Index of next frame that will be added to frames_. More... | |
int gmx::internal::AnalysisDataStorageImpl::computeStorageLocation | ( | int | index | ) | const |
Computes index into frames_ for accessing frame index
.
[in] | index | Zero-based frame index. |
-1 | if index is not available in frames_. |
Does not throw.
size_t gmx::internal::AnalysisDataStorageImpl::endStorageLocation | ( | ) | const |
Computes an index into frames_ that is one past the last frame stored.
Does not throw.
void gmx::internal::AnalysisDataStorageImpl::extendBuffer | ( | size_t | newSize | ) |
Extends frames_ to a new size.
std::bad_alloc | if out of memory. |
AnalysisDataFrameBuilderPointer gmx::internal::AnalysisDataStorageImpl::getFrameBuilder | ( | ) |
Returns a frame builder object for use with a new frame.
std::bad_alloc | if out of memory. |
|
inline |
Returns whether data needs to be stored at all.
This is used to optimize multipoint handling for parallel cases (where shouldNotifyImmediately() returns false), where it is not necessary to store even a single frame.
Does not throw.
void gmx::internal::AnalysisDataStorageImpl::rotateBuffer | ( | ) |
Remove oldest frame from the storage to make space for a new one.
Increments firstFrameLocation_ and reinitializes the frame that was made unavailable by this operation.
Does not throw.
|
inline |
Returns whether notifications should be immediately fired.
This is used to optimize multipoint handling for non-parallel cases, where it is not necessary to store even a single frame.
Does not throw.
|
inline |
Whether storage of all frames has been requested.
Storage of all frames also works as expected if storageLimit_ is used in comparisons directly, but this method should be used to check how to manage frames_.
FrameBuilderList gmx::internal::AnalysisDataStorageImpl::builders_ |
Currently unused frame builders.
The builders are cached to avoid repeatedly allocating memory for them. Typically, there are as many builders as there are concurrent users of the storage object. Whenever a frame is started, a builder is pulled from this pool by getFrameBuilder() (a new one is created if none are available), and assigned for that frame. When that frame is finished, the builder is returned to this pool.
FrameList gmx::internal::AnalysisDataStorageImpl::frames_ |
Data frames that are currently stored.
If storage of all frames has been requested, this is simply a vector of frames up to the latest frame that has been started. In this case, firstFrameLocation_ is always zero.
If storage of all frames is not requested, this is a ring buffer of frames of size n=storageLimit_+pendingLimit_+1
. If a frame with index index
is currently stored, its location is indexframes_.size
(). When at most storageLimit_ first frames have been finished, this contains storage for the first n-1
frames. When more than storageLimit_ first frames have been finished, the oldest stored frame is stored in the location firstFrameLocation_, and storageLimit_ frames starting from this location are the last finished frames. pendingLimit_ frames follow, and some of these may be in progress or finished. There is always one unused frame in the buffer, which is initialized such that when firstFrameLocation_ is incremented, it becomes valid. This makes it easier to rotate the buffer in concurrent access scenarions (which are not yet otherwise implemented).
int gmx::internal::AnalysisDataStorageImpl::nextIndex_ |
Index of next frame that will be added to frames_.
If all frames are not stored, this will be the index of the unused frame (see frames_).
int gmx::internal::AnalysisDataStorageImpl::pendingLimit_ |
Number of future frames that may need to be started.
Should always be at least one.
int gmx::internal::AnalysisDataStorageImpl::storageLimit_ |
Number of past frames that need to be stored.
Always non-negative. If storage of all frames has been requested, this is set to a large number.