Last active
August 17, 2018 21:07
-
-
Save sayden/c2328c18a40d8f7d6ef7ae32efcce484 to your computer and use it in GitHub Desktop.
timeAfter
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
package time_profile | |
import "time" | |
func timeAfter() chan struct{} { | |
ch := make(chan struct{}) | |
go timeAfterGoroutine(ch) | |
return ch | |
} | |
func timeAfterGoroutine(ch chan struct{}) { | |
waitduration := 5000 * time.Millisecond | |
rand.Seed(33) | |
for { | |
select { | |
case _ = <-ch: | |
case <-time.After(waitduration): | |
} | |
} | |
log.Info("Finished") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment