Created
          August 17, 2018 21:11 
        
      - 
      
- 
        Save sayden/4660f76d0147ce88fce1a8ce866d1c9d to your computer and use it in GitHub Desktop. 
    timer
  
        
  
    
      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
    
  
  
    
  | package time_profile | |
| import "time" | |
| func newTimer() chan struct{} { | |
| ch := make(chan struct{}) | |
| go func(ch chan struct{}) { | |
| waitduration := 5000 * time.Millisecond | |
| timer := time.NewTimer(waitduration) | |
| for { | |
| select { | |
| case _ = <-ch: | |
| case <-timer.C: | |
| } | |
| timer.Reset(waitduration) | |
| } | |
| log.Info("Finished") | |
| }(ch) | |
| return ch | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment