mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 00:23:18 +00:00
81367893fd
The idiomatic pattern for signalling a one-time message to multiple consumers from a single producer is as follows: ``` c := make(chan struct{}) w := new(sync.WaitGroup) // Boilerplate to ensure synchronization. for i := 0; i < 1000; i++ { w.Add(1) go func() { defer w.Done() for { select { case _, ok := <- c: if !ok { return } default: // Do something here. } } }() } close(c) // Signal the one-to-many single-use message. w.Wait() ``` Change-Id: I755f73ba4c70a923afd342a4dea63365bdf2144b |
||
---|---|---|
.. | ||
metric | ||
raw | ||
remote | ||
interface.go |