Level / classic-level

An abstract-level database backed by LevelDB.
MIT License
58 stars 11 forks source link

Support abort signal in iterator.all() #13

Open ronag opened 2 years ago

ronag commented 2 years ago

Currently there is no good way to abort a iterator.all() call. Would be nice if the api could support AbortController.

vweevers commented 2 years ago

If your all() call is a long-running operation (getting many entries) it might not be the best method to use. For that same reason, all() currently uses nextv() under the hood, rather than a dedicated and optimized C++ method for all(). Because I assumed that the iterator typically just needs a few nextv() calls to get all entries. That does give us a way to abort, in between nextv() calls, but I'm not sure that fits your use case.

Assuming that we did have such a dedicated method, let's say iterator_all() - how would we cancel the async work in C++?

vweevers commented 1 year ago

https://github.com/Level/abstract-level/pull/55 (as noted there, implementations have to handle the aborting, so there will be additional work here).