mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Reset ArrayPortalToken when Detach is called
When `ArrayPortalToken::Detach` was called, the contained `Token` was detached, but `ArrayPortal` being wrapped might also be holding its own portal that it is decorating. To ensure that any dependent portals are also detached, `ArrayPortalToken::Detach` resets itself.
This commit is contained in:
parent
53c17a6876
commit
75cb53d3ad
@ -91,7 +91,14 @@ public:
|
||||
///
|
||||
/// This will open up the `ArrayHandle` for reading and/or writing.
|
||||
///
|
||||
VTKM_CONT void Detach() { this->Token->DetachFromAll(); }
|
||||
VTKM_CONT void Detach()
|
||||
{
|
||||
this->Token->DetachFromAll();
|
||||
|
||||
// Reset this portal in case the superclass is holding other array portals with their own
|
||||
// tokens. Detach is supposed to invalidate the array portal, so it is OK to do this.
|
||||
*this = ArrayPortalToken<PortalType_>();
|
||||
}
|
||||
|
||||
/// \brief Get the `Token` of the `ArrayPortal`.
|
||||
///
|
||||
|
@ -217,6 +217,15 @@ struct Test
|
||||
// the concreteArray getting locked up.
|
||||
CheckPortal(virtualArray.ReadPortal());
|
||||
SetPortal(concreteArray.WritePortal());
|
||||
|
||||
// Make sure Detach also correctly unlocks the concrete array.
|
||||
auto readPortal = virtualArray.ReadPortal();
|
||||
readPortal.Detach();
|
||||
concreteArray.WritePortal();
|
||||
|
||||
auto writePortal = virtualArray.WritePortal();
|
||||
writePortal.Detach();
|
||||
concreteArray.WritePortal();
|
||||
}
|
||||
|
||||
void operator()()
|
||||
|
Loading…
Reference in New Issue
Block a user