Skip to content

Ahead of time object creation/recycling #167

@bikeshedder

Description

@bikeshedder

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coreArea: Core / deadpoolenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions