Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Process the measuring points.
- func MeasuringPointsDo(f func(*MeasuringPoint)) {
- // Get a channel with the measuring points.
- outChan := make(chan *MeasuringPoint)
- measuringPointOutChanChan <- outChan
- // Process the points.
- for mp := range outChan {
- f(mp)
- }
- }
- // The measuring backend goroutine.
- func etmBackend() {
- measurings := make(map[string]*MeasuringPoint)
- for {
- select {
- case measuring := <-measuringInChan:
- // Received a new measuring.
- if mp, ok := measurings[measuring.id]; ok {
- // Measuring point found.
- mp.update(measuring)
- measurings[measuring.id] = mp
- } else {
- // New measuring point.
- measurings[measuring.id] = newMeasuringPoint(measuring)
- }
- case outChan := <-measuringPointOutChanChan:
- // Retrieve the measuring points.
- go func() {
- for _, mp := range measurings {
- outChan <- mp
- }
- }()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement