DynamicIterators.jl icon indicating copy to clipboard operation
DynamicIterators.jl copied to clipboard

Ressource management

Open mschauer opened this issue 7 years ago • 3 comments

One could wonder if DynamicIterators should support the notion of closing iterators to facilitate ressource management.

mschauer avatar Nov 12 '18 11:11 mschauer

It appears that this can be done with minimal overhead. Basically, iterators already implement message passing with the message nothing for starting and stopping.

mschauer avatar Nov 13 '18 17:11 mschauer

The solution can be to define a "PostProcess(state, message)" state which sends Close() up-range.

mschauer avatar Nov 14 '18 07:11 mschauer

I added an example explaining how this can be done:

https://github.com/mschauer/DynamicIterators.jl/blob/master/example/ressourcemanagement.jl

mschauer avatar Nov 14 '18 13:11 mschauer