Open kijanawoodard opened 9 months ago
That's an interesting idea and I don't see any obvious reason why it wouldn't work, but I also can't recall having heard a request for that before.
Are there other async-factory types you need to pool or is it just IBrowser
? If it's just browsers, do you need a scalable number of instances or can you just pre-allocate the number you require and then consume them from a simpler collection, like a list?
I don't have another case off the top of my head, but "everything's async now".
I was about to criticize another dev for not using the object pool, but decided to just take a crack at it myself. Ran square into this issue.
I ended up building a custom pool + pool policy. I skipped the pool provider. It's not awful, but it would have been nice to be able to use the bcl pool.
One of the few exceptions to the "everything's async" heuristic is object initialization, which remains stubbornly synchronous. For pool rental to be substitutable for new
, it has to be synchronous too.
Let's keep this around and see if any other use cases arise.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
I also strongly agree with this idea. I heavily use object pools for many different scenarios. And some of these classes (if not most) need async initialization after constructing a new instance. Even some don't have a constructor, yet a static async Create factory method. Such as the given example here Playwright's Browser initialization. Or ConnectionMultiplexer of Redis.. It's another discussion topic if these classes really need to be pooled or not. It doesn't change the fact there is always a use case.
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I'm trying to create an IPooledObjectPolicy where IBrowser is from Playwright.net. However, Playwright's method to create an IBroswer is
LaunchBrowserAsync
.Describe the solution you'd like
An async ObjectPool stack would be nice.
I'm guessing the viral nature of async makes this a more complex feature request?
Additional context
No response