MCPcopy
hub / github.com/andeya/pholcus / Call

Method Call

common/pool/pool.go:68–101  ·  view source on GitHub ↗

Call invokes the callback with a resource from the pool.

(callback func(Src) error)

Source from the content-addressed store, hash-verified

66
67// Call invokes the callback with a resource from the pool.
68func (c *classic) Call(callback func(Src) error) result.VoidResult {
69 var src Src
70 for {
71 c.RLock()
72 if c.closed {
73 c.RUnlock()
74 return result.TryErrVoid(closedError)
75 }
76 select {
77 case src = <-c.srcs:
78 c.RUnlock()
79 if !src.Usable() {
80 c.del(src)
81 continue
82 }
83 default:
84 c.RUnlock()
85 err := c.incAuto()
86 if err != nil {
87 return result.TryErrVoid(err)
88 }
89 runtime.Gosched()
90 continue
91 }
92 break
93 }
94 defer func() {
95 if p := recover(); p != nil {
96 _ = fmt.Errorf("%v", p)
97 }
98 c.recover(src)
99 }()
100 return result.RetVoid(callback(src))
101}
102
103// Close destroys the pool and releases all resources.
104func (c *classic) Close() {

Callers

nothing calls this directly

Calls 5

UsableMethod · 0.95
delMethod · 0.95
incAutoMethod · 0.95
recoverMethod · 0.95
callbackFunction · 0.85

Tested by

no test coverage detected