Last active
August 29, 2015 14:08
-
-
Save ironsmile/52ab6202fc99b56310c7 to your computer and use it in GitHub Desktop.
ranging over channel after selecting from it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for { | |
| select { | |
| case elem := <-a.traffChan: | |
| a.aggregateTraff(elem.header, elem.body) | |
| //!TODO maybe return elem to the pool | |
| case elem := <-a.hitChan: | |
| a.aggregateHit(elem.header, elem.body) | |
| //!TODO maybe return elem to the pool | |
| case <-a.stopChan: | |
| close(a.traffChan) | |
| for elem := range a.traffChan { | |
| a.aggregateTraff(elem.header, elem.body) | |
| } | |
| close(a.hitChan) | |
| for elem := range a.hitChan { | |
| a.aggregateHit(elem.header, elem.body) | |
| } | |
| a.aggregationStopped <- struct{}{} | |
| return | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment