type countingPromise … var _ … // NewCountingWriteOnce creates a WriteOnce that uses locking and counts goroutine activity. // // The final three arguments are like those for a regular WriteOnce factory: // - an optional initial value, // - an optional "done" channel, // - the value that is Set after the "done" channel becomes selectable. // Note that for this implementation, the reaction to `doneCh` // becoming selectable does not wait for a Get. // If `doneCh != nil` then the caller promises to close it reasonably promptly // (to the degree allowed by the Go runtime scheduler), and increment the // goroutine counter before that. // The WriteOnce's Get method must be called without the lock held. // The WriteOnce's Set method must be called with the lock held. func NewCountingWriteOnce(activeCounter counter.GoRoutineCounter, lock sync.Locker, initial interface{ … } func (p *countingPromise) Get() interface{ … } func (p *countingPromise) Set(value interface{ … }