Created
February 14, 2015 21:43
-
-
Save shadedyin/dfe759736848ff095426 to your computer and use it in GitHub Desktop.
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 hold | |
import ( | |
"time" | |
) | |
func Hold(read chan interface{}, timeout time.Duration) interface{} { | |
var result interface{} | |
for { | |
select { | |
case <-time.After(timeout * time.Second): | |
return result | |
case result = <-read: | |
// update tmp | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment