releaseAll method
Releases all resources that this Arena manages.
If reuse
is true
, the arena can be used again after resources
have been released. If not, the default, then the allocate
and using methods must not be called after a call to releaseAll
.
If any of the callbacks throw, releaseAll is interrupted, and should be started again.
Implementation
void releaseAll({bool reuse = false}) {
if (!reuse) {
_inUse = false;
}
// The code below is deliberately wirtten to allow allocations to happen
// during `releaseAll(reuse:true)`. The arena will still be guaranteed
// empty when the `releaseAll` call returns.
while (_managedResourceReleaseCallbacks.isNotEmpty) {
_managedResourceReleaseCallbacks.removeLast()();
}
for (final p in _managedMemoryPointers) {
_wrappedAllocator.free(p);
}
_managedMemoryPointers.clear();
}