jackfirth / racket-disposable

An experimental Racket library providing an abstraction for values associated with external resources that allows automatic resource pooling, per-thread virtual construction, and monadic composition
Apache License 2.0
7 stars 0 forks source link

Add disposable acquirer #104

Open jackfirth opened 7 years ago

jackfirth commented 7 years ago

Bit of a meta idea here:

(with-disposable ([acquirer disposable-acquire])
  (define foo (acquirer foo-disp))
  (define bar (acquirer bar-disp))
  ... do stuff with foo and bar ...)

Essentially, it's a disposable of an "acquirer" - a function that can be used to allocate other disposables. When the acquirer is disposed, all values allocated with it are disposed and all future attempts to call it will fail. This ended up being useful in the implementation of #96.