package gate provides a mechanism by which independent workers can wait for one another to finish a task, without introducing explicit dependencies between those workers.



    This section is empty.


    View Source
    var ErrUnlocked = errors.New("gate unlocked")

      ErrUnlocked indicates that a Flag's gate has been unlocked and it should be restarted to reflect the new value.


      func FlagManifold

      func FlagManifold(config FlagManifoldConfig) dependency.Manifold

        FlagManifold runs a worker that implements engine.Flag such that it's only considered set when the referenced gate is unlocked.

        func Manifold

        func Manifold() dependency.Manifold

          Manifold returns a dependency.Manifold that wraps a single channel, shared across all workers returned by the start func; it can be used to synchronize operations across manifolds that lack direct dependency relationships.

          The output func accepts an out pointer to either an Unlocker or a Waiter.

          func ManifoldEx

          func ManifoldEx(lock Lock) dependency.Manifold

            ManifoldEx does the same thing as Manifold but takes the Lock which used to wait on or unlock the gate. This allows code running outside of a dependency engine managed worker to monitor or unlock the gate.

            TODO(mjs) - this can likely go away once all machine agent workers are running inside the dependency engine.

            func NewFlagWorker

            func NewFlagWorker(gate Waiter) (worker.Worker, error)


            type AlreadyUnlocked

            type AlreadyUnlocked struct{}

              AlreadyUnlocked is a Waiter that always reports its gate to be unlocked.

              func (AlreadyUnlocked) IsUnlocked

              func (AlreadyUnlocked) IsUnlocked() bool

                IsUnlocked is part of the Waiter interface.

                func (AlreadyUnlocked) Unlocked

                func (AlreadyUnlocked) Unlocked() <-chan struct{}

                  Unlocked is part of the Waiter interface.

                  type Flag

                  type Flag struct {
                  	// contains filtered or unexported fields

                    Flag uses a gate to implement engine.Flag.

                    func NewFlag

                    func NewFlag(gate Waiter) (*Flag, error)

                      NewFlag returns a worker that implements engine.Flag, backed by the supplied gate's unlockedness.

                      func (*Flag) Check

                      func (w *Flag) Check() bool

                        Check is part of the engine.Flag interface.

                        func (*Flag) Kill

                        func (w *Flag) Kill()

                          Kill is part of the worker.Worker interface.

                          func (*Flag) Wait

                          func (w *Flag) Wait() error

                            Wait is part of the worker.Worker interface.

                            type FlagManifoldConfig

                            type FlagManifoldConfig struct {
                            	GateName  string
                            	NewWorker func(gate Waiter) (worker.Worker, error)

                              FlagManifoldConfig holds the dependencies required to run a Flag in a dependency.Engine.

                              type Lock

                              type Lock interface {

                                Lock combines the Waiter and Unlocker interfaces.

                                func NewLock

                                func NewLock() Lock

                                  NewLock returns a new Lock for the gate manifold, suitable for passing to ManifoldEx. It can be safely unlocked and monitored by code running inside or outside of the dependency engine.

                                  type Unlocker

                                  type Unlocker interface {

                                    Unlocker is used to unlock a shared gate.

                                    type Waiter

                                    type Waiter interface {
                                    	Unlocked() <-chan struct{}
                                    	IsUnlocked() bool

                                      Waiter is used to wait for a shared gate to be unlocked.