MCPcopy Index your code
hub / github.com/goinaction/code / Close

Method Close

chapter7/patterns/pool/pool.go:83–104  ·  view source on GitHub ↗

Close will shutdown the pool and close all existing resources.

()

Source from the content-addressed store, hash-verified

81
82// Close will shutdown the pool and close all existing resources.
83func (p *Pool) Close() {
84 // Secure this operation with the Release operation.
85 p.m.Lock()
86 defer p.m.Unlock()
87
88 // If the pool is already close, don't do anything.
89 if p.closed {
90 return
91 }
92
93 // Set the pool as closed.
94 p.closed = true
95
96 // Close the channel before we drain the channel of its
97 // resources. If we don't do this, we will have a deadlock.
98 close(p.resources)
99
100 // Close the resources
101 for r := range p.resources {
102 r.Close()
103 }
104}

Callers 9

ReleaseMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
RetrieveFeedsFunction · 0.45
retrieveMethod · 0.45
TestDownloadFunction · 0.45
TestDownloadFunction · 0.45
TestDownloadFunction · 0.45

Calls 2

LockMethod · 0.65
UnlockMethod · 0.65

Tested by 3

TestDownloadFunction · 0.36
TestDownloadFunction · 0.36
TestDownloadFunction · 0.36