CheckIn checks in an instance to the pool and hangs while instance with same identity is using the lock.
(identity string)
| 37 | // CheckIn checks in an instance to the pool and hangs while instance |
| 38 | // with same identity is using the lock. |
| 39 | func (p *ExclusivePool) CheckIn(identity string) { |
| 40 | p.lock.Lock() |
| 41 | |
| 42 | lock, has := p.pool[identity] |
| 43 | if !has { |
| 44 | lock = &sync.Mutex{} |
| 45 | p.pool[identity] = lock |
| 46 | } |
| 47 | p.count[identity]++ |
| 48 | |
| 49 | p.lock.Unlock() |
| 50 | lock.Lock() |
| 51 | } |
| 52 | |
| 53 | // CheckOut checks out an instance from the pool and releases the lock |
| 54 | // to let other instances with same identity to grab the lock. |
no outgoing calls
no test coverage detected