goio icon indicating copy to clipboard operation
goio copied to clipboard

Resource management in streams

Open Primetalk opened this issue 2 years ago • 3 comments

Currently streams can only use resources provided at the top level via ordinary resource.Use. Sometimes we need to pass streams around and we wish that resources are correctly released when stream is either finished or thrown away.

Primetalk avatar Jun 17 '22 09:06 Primetalk

This requires adding a finalizer to all stream steps. Then in every stream executor, these finalizers should be respected and appended to io.

Primetalk avatar Aug 24 '22 20:08 Primetalk

Signature might look like

stream.Finally[A any](stm stream.Stream[A], func () io.IOUnit) stream.Stream[A]

Primetalk avatar Sep 05 '22 20:09 Primetalk

There are two FStreams - one that is just a pair of stream and IO to finalize, and another one - IO of such pair. The difference is that IO represents a stream that has not yet been started.

Primetalk avatar Jan 14 '23 13:01 Primetalk