mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Preserve data in ArrayHandle::ReleaseResourcesExecution
Previously when ReleaseResourcesExecution was called, the method blindly deleted the execution array regardless of whether there was a valid copy in the control environment. This could potentially lose data. What if someone wanted to conserve memory on the device by clearing the array of an output array? There is also now an internal method that blindly deletes the array. This is good for internal functions that are doing something to invalidate the execution data anyway.
This commit is contained in:
parent
68ae208dad
commit
2f781dfe7a
@ -174,7 +174,7 @@ public:
|
||||
// If the user writes into the iterator we return, then the execution
|
||||
// array will become invalid. Play it safe and release the execution
|
||||
// resources. (Use the const version to preserve the execution array.)
|
||||
this->ReleaseResourcesExecution();
|
||||
this->ReleaseResourcesExecutionInternal();
|
||||
return this->Internals->ControlArray.GetPortal();
|
||||
}
|
||||
else
|
||||
@ -273,18 +273,18 @@ public:
|
||||
///
|
||||
VTKM_CONT_EXPORT void ReleaseResourcesExecution()
|
||||
{
|
||||
if (this->Internals->ExecutionArrayValid)
|
||||
{
|
||||
this->Internals->ExecutionArray->ReleaseResources();
|
||||
this->Internals->ExecutionArrayValid = false;
|
||||
}
|
||||
// Save any data in the execution environment by making sure it is synced
|
||||
// with the control environment.
|
||||
this->SyncControlArray();
|
||||
|
||||
this->ReleaseResourcesExecutionInternal();
|
||||
}
|
||||
|
||||
/// Releases all resources in both the control and execution environments.
|
||||
///
|
||||
VTKM_CONT_EXPORT void ReleaseResources()
|
||||
{
|
||||
this->ReleaseResourcesExecution();
|
||||
this->ReleaseResourcesExecutionInternal();
|
||||
|
||||
// Forget about any user iterators.
|
||||
this->Internals->UserPortalValid = false;
|
||||
@ -541,6 +541,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void ReleaseResourcesExecutionInternal()
|
||||
{
|
||||
if (this->Internals->ExecutionArrayValid)
|
||||
{
|
||||
this->Internals->ExecutionArray->ReleaseResources();
|
||||
this->Internals->ExecutionArrayValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<InternalStruct> Internals;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user