-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to .close() a stream? #4
Comments
+1 for a |
+1 for a |
would anyone like to submit PR? |
Would calling |
The rdfjs spec says:
What means "closing" exactly? In my opinion, if you close it manually, Streams wouldn't be readable-only anymore. Furthermore, what should happen, if there is a close function but its never called? I suggest, that you leave that to the implementation. For instance, an iterator could implement a function, which is called, when the object itself gets removed. For instance, in PHP there is a __destruct function, which can be overridden and is called, before object removal. This way, you can remove the iterator manually the release its resources. Maybe there is something similar in Java. |
Streams are read-only. By calling close, you signal that you will not read anymore, so no more resources need to be spent on generating items. Behind the scenes, for instance, HTTP connections could be closed, or file descriptors.
|
Sorry if this has been discussed before.
I am wondering how Streams (such as those returned by .match) are supposed to be walked and then, for example, stopped after the first element. Shouldn't there be some kind of a .close() function that releases the resources? As an example I am working on a Oracle Nashorn-based implementation of your API that runs a Jena Triple iterator in the background, and I need a clean way to call .close() on those Java objects. The contract would be that close() must be called unless the Stream is walked to exhaustion.
The text was updated successfully, but these errors were encountered: