Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert destroy methods to flag resources for destruction after release? #17

Open
myndzi opened this issue Sep 16, 2015 · 0 comments
Open

Comments

@myndzi
Copy link
Owner

myndzi commented Sep 16, 2015

Just had an idea to help eliminate double-release errors as well as make it easier for consumers of resource pools to deal with out-of-band error cases (inspired by knex/knex#973). Simply put, instead of removing the resource from the pool when .destroy() is called, instead we can flag it for removal and let things take their natural course. When the resource is released as cleanup, say by a disposer (as knex does), it will see that the resource has been flagged for destruction and remove it at that time.

An argument should be supplied to destroy, something like destroy(defer), to maintain existing behavior as well as avoid making more work in work flows where the caller would not need a global cleanup handler and just wants to destroy immediately.

Logging this issue as a todo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant