allowRelease method
void
allowRelease(
- dynamic onRelease(
Tells the parent Pool that the resource associated with this resource is no longer necessary, but should remain allocated until more resources are needed.
When Pool.request is called and there are no remaining available
resources, the onRelease
callback is called. It should free the
resource, and it may return a Future or null
. Once that completes, the
Pool.request call will complete to a new PoolResource.
This is useful when a resource's main function is complete, but it may produce additional information later on. For example, an isolate's task may be complete, but it could still emit asynchronous errors.
Implementation
void allowRelease(Function() onRelease) {
if (_released) {
throw StateError('A PoolResource may only be released once.');
}
_released = true;
_pool._onResourceReleaseAllowed(onRelease);
}