I recently published `disposable`, an experimental package for safely handling external resources.
Features: - representation of a "disposable", a producer of values with external resources that must be disposed - safe handling of disposables for multiple usage patterns, including: - for a series of expressions, `(with-disposable ([v disp]) body ...)` - for the lifetime of the program with the resource cleaned up on program exit, `(acquire-global disp)` - for the lifetime of the current thread, with a single resource reused automatically in the same thread, `(acquire-virtual disp)` (heavily inspired by virtual connections in the `db` library) - until an arbitrary event is ready for synchronization, `(acquire disp #:dispose-evt (alarm-evt 1000))` - abstractions over disposables and combinators for extending disposables, including: - creating a pool of disposable values with reuse, `(disposable-pool disp)` - asynchronously deallocating disposables, `(disposable/async-dealloc disp)` - monadically composing disposables with concurrent allocation and deallocation, `(disposable-apply f disp ...)` and `(disposable-chain disp f)` - temporary files and directories as disposables - utilities for testing disposables, including observing when allocation and deallocation occur If you're familiar with AutoClosable in Java or IDisposable in C#, think of disposables as thunks that produce AutoClosable or IDisposable values. The API is still in the early stages, and there's a few concurrency bugs to work out but the features above should work as advertised. Feedback strongly welcomed. Docs: http://docs.racket-lang.org/disposable/ Source code: https://github.com/jackfirth/racket-disposable -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.