Last active
October 17, 2016 20:02
-
-
Save arschles/5d608b1e0d2f419af0ccdc7efe7e8f25 to your computer and use it in GitHub Desktop.
for/select loop for tickers & timers
This file contains 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
i := 0 | |
for { | |
select { | |
case <- timer.C: | |
return | |
case <-ticker.C: | |
fn(i) | |
i++ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment