| 12 | type PromiseMap map[interface{}]Promise |
| 13 | |
| 14 | type LockMap interface { |
| 15 | // Wait returns the Promise for a key. |
| 16 | // If the Promise is expired, it will be resolved, but this function will return nil |
| 17 | Wait(key interface{}) Promise |
| 18 | |
| 19 | // WaitOrLock takes the lock, but only if none exists for that key. |
| 20 | // If the Promise is expired, it will successfully replace it and the previous Promise will be resolved. |
| 21 | WaitOrLock(key interface{}, ttl time.Duration) (promise Promise, gotLock bool) |
| 22 | |
| 23 | // Release unlocks a key and resolved the previous Promise, if any. |
| 24 | Release(key interface{}) |
| 25 | |
| 26 | // Allows the LockMap to be started and stopped externally |
| 27 | Tomb() *tomb.Tomb |
| 28 | Run() error |
| 29 | } |
| 30 | |
| 31 | func New(sweepInterval time.Duration, tomb *tomb.Tomb) LockMap { |
| 32 | return &lockMap{ |
no outgoing calls
no test coverage detected