Resource management

Isiah Meadows isiahmeadows at gmail.com
Tue Jan 10 00:23:52 UTC 2017


I'll note that the disposer pattern is a lot like Ruby's resource
management idioms as well (probably closer). The biggest issue I've seen
with it so far is only how hard it is to compose while still avoiding
leaks. Using one resource like that is easy, but joining multiple resources
to use them simultaneously is much harder, and really requires some sort of
abstraction. Promises complicate that further in that you have to
effectively save an async continuation for each resource just to call back
into them when done. Another complication is that some may end up
unsuccessful, so you have to continue those that do succeed.

As for any decent resource management, the current idioms suck, but I'm not
sure what would be better.

On Fri, Jan 6, 2017, 04:38 Benjamin Gruenbaum <benjamingr at gmail.com> wrote:

> Oh, Bluebird's `Promise.using` does that with very high certainly. The
> reason we introduced `using` rather than let people just use the disposer
> pattern is because it is very tricky to get right in userland - so the
> library provided it.
>
> On Fri, Jan 6, 2017 at 2:51 AM, Isiah Meadows <isiahmeadows at gmail.com>
> wrote:
>
> It'd be nice to have something like that reified into the language
> somehow. I'll note that Bluebird's gotcha with `Promise.using`
> multiple resources simultaneously is a huge issue, though, and it
> should be avoided for anything standardized. (If one of them fail, the
> rest should be closed either immediately or as soon as they are
> available, to avoid resource leaks.)
> -----
>
> Isiah Meadows
> me at isiahmeadows.com
>
>
> On Mon, Jan 2, 2017 at 10:04 AM, Benjamin Gruenbaum
> <benjamingr at gmail.com> wrote:
> > And, on a similar note - a pattern has emerged in userland libraries all
> > over:
> >
> http://stackoverflow.com/questions/28915677/what-is-the-promise-disposer-pattern
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
> >
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170110/f6b565d4/attachment.html>


More information about the es-discuss mailing list