github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/worker/gate/interface.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 // package gate provides a mechanism by which independent workers can wait for 5 // one another to finish a task, without introducing explicit dependencies 6 // between those workers. 7 package gate 8 9 // Unlocker is used to unlock a shared gate. 10 type Unlocker interface { 11 Unlock() 12 } 13 14 // Waiter is used to wait for a shared gate to be unlocked. 15 type Waiter interface { 16 Unlocked() <-chan struct{} 17 } 18 19 // AlreadyUnlocked is a Waiter that always reports its gate to be unlocked. 20 type AlreadyUnlocked struct{} 21 22 // Unlocked is part of the Waiter interface. 23 func (AlreadyUnlocked) Unlocked() <-chan struct{} { 24 ch := make(chan struct{}) 25 close(ch) 26 return ch 27 }