func (catacomb *Catacomb) Add(w worker.Worker) error {
	select {
	case <-catacomb.tomb.Dying():
		if err := worker.Stop(w); err != nil {
			return errors.Trace(err)
		}
		return catacomb.ErrDying()
	case catacomb.adds <- w:
		// Note that we don't need to wait for confirmation here. This depends
		// on the catacomb.wg.Add() for the listen loop, which ensures the wg
		// won't complete until no more adds can be received.
		return nil
	}
}
// Add causes the supplied worker's lifetime to be bound to the catacomb's,
// relieving the client of responsibility for Kill()ing it and Wait()ing for an
// error, *whether or not this method succeeds*. If the method returns an error,
// it always indicates that the catacomb is shutting down; the value will either
// be the error from the (now-stopped) worker, or catacomb.ErrDying().
//
// If the worker completes without error, the catacomb will continue unaffected;
// otherwise the catacomb's tomb will be killed with the returned error. This
// allows clients to freely Kill() workers that have been Add()ed; any errors
// encountered will still kill the catacomb, so the workers stay under control
// until the last moment, and so can be managed pretty casually once they've
// been added.
//
// Don't try to add a worker to its own catacomb; that'll deadlock the shutdown
// procedure. I don't think there's much we can do about that.
Add causes the supplied worker's lifetime to be bound to the catacomb's,
relieving the client of responsibility for Kill()ing it and Wait()ing for an
error, *whether or not this method succeeds*. If the method returns an error,
it always indicates that the catacomb is shutting down; the value will either
be the error from the (now-stopped) worker, or catacomb.ErrDying().

If the worker completes without error, the catacomb will continue unaffected;
otherwise the catacomb's tomb will be killed with the returned error. This
allows clients to freely Kill() workers that have been Add()ed; any errors
encountered will still kill the catacomb, so the workers stay under control
until the last moment, and so can be managed pretty casually once they've
been added.

Don't try to add a worker to its own catacomb; that'll deadlock the shutdown
procedure. I don't think there's much we can do about that.
// Add causes the supplied worker ' s lifetime to be bound to the catacomb ' s // relieving the client of responsibility for Kill () ing it and Wait () ing for an // error * whether or not this method succeeds * . If the method returns an error // it always indicates that the catacomb is shutting down ; the value will either // be the error from the ( now - stopped ) worker or catacomb . ErrDying () . // // If the worker completes without error the catacomb will continue unaffected ; // otherwise the catacomb ' s tomb will be killed with the returned error . This // allows clients to freely Kill () workers that have been Add () ed ; any errors // encountered will still kill the catacomb so the workers stay under control // until the last moment and so can be managed pretty casually once they ' ve // been added . // // Don ' t try to add a worker to its own catacomb ; that ' ll deadlock the shutdown // procedure . I don ' t think there ' s much we can do about that .
func (catacomb *Catacomb) Add(w worker.Worker) error {
	select {
	case <-catacomb.tomb.Dying():
		if err := worker.Stop(w); err != nil {
			return errors.Trace(err)
		}
		return catacomb.ErrDying()
	case catacomb.adds <- w:
		return nil
	}
}
func ( catacomb * Catacomb ) Add ( w worker . Worker ) error { select { case <- catacomb . tomb . Dying ( ) : if err := worker . Stop ( w ) ; err != nil { return errors . Trace ( err ) } return catacomb . ErrDying ( ) case catacomb . adds <- w : return nil } }
Add causes the supplied worker's lifetime to be bound to the catacomb's,
relieving the client of responsibility for Kill()ing it and Wait()ing for an
error, *whether or not this method succeeds*.
Add causes the supplied worker ' s lifetime to be bound to the catacomb ' s relieving the client of responsibility for Kill () ing it and Wait () ing for an error * whether or not this method succeeds * .
// Note that we don't need to wait for confirmation here. This depends // on the catacomb.wg.Add() for the listen loop, which ensures the wg // won't complete until no more adds can be received.