Skip to content
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

Add new configuration: minimum count of elements. #352

Closed
xuxiaocheng0201 opened this issue Sep 9, 2024 · 3 comments
Closed

Add new configuration: minimum count of elements. #352

xuxiaocheng0201 opened this issue Sep 9, 2024 · 3 comments
Labels
A-core Area: Core / deadpool enhancement New feature or request S-duplicate Status: This issue or pull request already exists

Comments

@xuxiaocheng0201
Copy link

In my particular example, I need to retain at least one element in the pool. Is there any way to achieve this?

@bikeshedder bikeshedder added the question Further information is requested label Sep 9, 2024
@bikeshedder
Copy link
Owner

What are you trying to do? Are you calling deadpool::managed::Pool::retain and just want one element to exist afterwards?

The simplest way I can think of would be this:

let item = pool.get().await;
pool.retain(|_, _| false);

This would cause one object to be grabbed from the pool. Then retain removes all other elements and afterwards that element is returned back to the pool.

This might actually be related to:

@xuxiaocheng0201
Copy link
Author

Thanks for your quick reply.

Actually the retain isn't what I want. I want at least one element which has the same lifetime with the pool.
A tuple containing a element and the pool is possible. But this is not perfect because the extra element cannot be used.

@xuxiaocheng0201
Copy link
Author

This is duplicate with #245. I will subscribe that issus.

@xuxiaocheng0201 xuxiaocheng0201 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
@bikeshedder bikeshedder added S-duplicate Status: This issue or pull request already exists enhancement New feature or request A-core Area: Core / deadpool and removed question Further information is requested labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core / deadpool enhancement New feature or request S-duplicate Status: This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants