Closed xuxiaocheng0201 closed 2 months ago
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:
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.
This is duplicate with #245. I will subscribe that issus.
In my particular example, I need to retain at least one element in the pool. Is there any way to achieve this?