mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-05 05:24:16 -04:00
Rename coordinator to bootstrapper and rename roles
This commit is contained in:
parent
3280ed200c
commit
916e5d6b55
191 changed files with 1763 additions and 2030 deletions
25
bootstrapper/internal/nodelock/nodelock.go
Normal file
25
bootstrapper/internal/nodelock/nodelock.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package nodelock
|
||||
|
||||
import "sync"
|
||||
|
||||
// Lock locks the node once there the join or the init is at a point
|
||||
// where there is no turning back and the other operation does not need
|
||||
// to continue.
|
||||
//
|
||||
// This can be viewed as a state machine with two states: unlocked and locked.
|
||||
// There is no way to unlock, so the state changes only once from unlock to
|
||||
// locked.
|
||||
type Lock struct {
|
||||
mux *sync.Mutex
|
||||
}
|
||||
|
||||
// New creates a new NodeLock, which is unlocked.
|
||||
func New() *Lock {
|
||||
return &Lock{mux: &sync.Mutex{}}
|
||||
}
|
||||
|
||||
// TryLockOnce tries to lock the node. If the node is already locked, it
|
||||
// returns false. If the node is unlocked, it locks it and returns true.
|
||||
func (n *Lock) TryLockOnce() bool {
|
||||
return n.mux.TryLock()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue