-
Notifications
You must be signed in to change notification settings - Fork 186
Description
It would be nice if objects could be created and/or recycled ahead of time. I don't plan on making this feature mandatory but rather add some additional methods that can be used by 3rd party code to modify the pool state.
This future should be opt-in and not enabled by default as highly contested pools with large loads already perform exceptionally well. See https://github.com/bikeshedder/async-pool-benchmark
I would like the code that performs the ahead of time creation/recycling to work with public exposed APIs of the pool rather than being part of the pool implementation itself.
For that to work the pool will need at least one new method that provides access to the currently queued objects without removing them from the pool. For objects not part of the pool a new sync pre_return hook could be added that can be used to filter out objects. This hook could then either spawn a new async task taking ownership of the Object and call Object::take in order to discard it.