PagePool/BrowserPool Add the MustGet method to replace Get, and Get returns an error for processing
Modify CleanUp method to prevent stucking
The PagePool.Get can now only accept create func() *Page as input, so there is no way to output the error that may exist in the create func other than using a closure or using recover, and it is inconvenient for users in a multi-routine environment to perform logical processing based on the actual error that occurred. I added the PagePool.MustGet method to solve this. However, I'm not sure whether this change would be in line with the original design.
Besides, PagePool.CleanUp may stuck while pp is not full (forget/panic to Put, etc). I also think this might be an issue when using PagePool. Use select to prevent stucking
Development guide
Link
Test on local before making the PR
PagePool Change
The
PagePool.Get
can now only acceptcreate func() *Page
as input, so there is no way to output the error that may exist in the create func other than using a closure or using recover, and it is inconvenient for users in a multi-routine environment to perform logical processing based on the actual error that occurred. I added thePagePool.MustGet
method to solve this. However, I'm not sure whether this change would be in line with the original design.Besides,
PagePool.CleanUp
may stuck whilepp
is not full (forget/panic to Put, etc). I also think this might be an issue when using PagePool. Useselect
to prevent stucking