-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support returning engines to pool via scope/using #7
Comments
Yeah, that's a good idea! My original use case was having one engine per web request so I couldn't use I think the issue will be that calling
I think it'd be fine to just use |
…o call ReturnEngineToPool To handle this, the engine is wrapped in a class that overrides Dispose and does the right thing. References #7 References https://github.com/Wyamio/Wyam/pull/452
Released in 3.0 |
I’m looking at the pattern suggested in the README:
I think it would be nicer to be able to do something like:
Though it would be more fragile (if JavaScripEngineSwitcher adds more methods to
IJsEngine
, we’d break until fixed), it might even be more convenient if the object returned bypool.GetScopedEngine()
implementedIJsEngine
and proxied everything butDispose()
down to the actualIJsEngine
. Then it could be even more sugary:I have chosen a new function name,
IJsPool.GetScopedEngine()
, because existing code written againstIJsPool.GetEngine()
might make assumptions that this change in API would render invalid. Or, perhaps you’re willing to make a breaking change since this library is still a bit younger andusing(){}
is awesome enough to be worth it? If the scoping wrapper implementedIJsEngine
and proxied methods to the wrapped realIJsEngine
, the change in API would be transparent to the caller (you could leaveReturnEngineToPool()
around and mark it with ObsoleteAttribute to encourage adoption ofusing(){}
).Thoughts? For now, I’m implementing something like this in my private code (using extension methods), but being able to use
using(){}
out of the box would make this library feel more complete.The text was updated successfully, but these errors were encountered: