Skip to content

Commit 6c73c6e

Browse files
Fixed the code back to original version.
1 parent 74a7726 commit 6c73c6e

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

‎chapter7/patterns/pool/pool.go‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,12 @@ func (p *Pool) Acquire() (io.Closer, error) {
5959

6060
// Release places a new resource onto the pool.
6161
func (p *Pool) Release(r io.Closer) {
62-
// Secure reading the closed flag.
63-
var isClosed bool
62+
// Secure this operation with the Close operation.
6463
p.Lock()
65-
{
66-
isClosed = p.closed
67-
}
68-
p.Unlock()
64+
defer p.Unlock()
6965

7066
// If the pool is closed, discard the resource.
71-
if isClosed {
67+
if p.closed {
7268
r.Close()
7369
return
7470
}

0 commit comments

Comments
 (0)