Skip to content

Commit

Permalink
modify tryget
Browse files Browse the repository at this point in the history
  • Loading branch information
bestmountain committed Apr 30, 2024
1 parent fd4df50 commit 93a60a7
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,8 @@ func (pp PagePool) Get(create func() *Page) *Page {
// TryGet a page from the pool, allow error. Use the [PagePool.Put] to make it reusable later.
func (pp PagePool) TryGet(create func() (*Page, error)) (*Page, error) {
p := <-pp
var err error
if p == nil {
p, err = create()
if err != nil {
return nil, err
}
return create()
}
return p, nil
}
Expand Down

0 comments on commit 93a60a7

Please sign in to comment.