Close overrides the Close method of the embedded provider. It releases the reference held by the caller on the underlying provider and if the provider's reference count reaches zero, it is removed from the store, and its Close method is also invoked.
()
| 82 | // provider's reference count reaches zero, it is removed from the store, and |
| 83 | // its Close method is also invoked. |
| 84 | func (wp *wrappedProvider) Close() { |
| 85 | ps := wp.store |
| 86 | ps.mu.Lock() |
| 87 | defer ps.mu.Unlock() |
| 88 | |
| 89 | wp.refCount-- |
| 90 | if wp.refCount == 0 { |
| 91 | wp.Provider.Close() |
| 92 | delete(ps.providers, wp.storeKey) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // Close overrides the Close method of the embedded provider to avoid release the |
| 97 | // already released reference. |