summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-10-04 13:09:41 -0700
committerGitHub <noreply@github.com>2017-10-04 13:09:41 -0700
commit07777f5ff9e0bde26abd0288164e5f73b6da992a (patch)
treeb0aa1eff510d1531d2924522e0e6f0e9bfd7ac29 /store
parentdc9b1a1d6a0fe7ad2e18597cb46f3874736b4b40 (diff)
downloadchat-07777f5ff9e0bde26abd0288164e5f73b6da992a.tar.gz
chat-07777f5ff9e0bde26abd0288164e5f73b6da992a.tar.bz2
chat-07777f5ff9e0bde26abd0288164e5f73b6da992a.zip
Fix races / finally remove global app for good (#7570)
* finally remove global app for good * test compilation fixes * fix races * fix deadlock * wake up write pump so it doesn't take forever to clean up
Diffstat (limited to 'store')
-rw-r--r--store/store.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/store/store.go b/store/store.go
index bc9aa8f1a..120778e84 100644
--- a/store/store.go
+++ b/store/store.go
@@ -18,6 +18,17 @@ type StoreResult struct {
type StoreChannel chan StoreResult
+func Do(f func(result *StoreResult)) StoreChannel {
+ storeChannel := make(StoreChannel, 1)
+ go func() {
+ result := StoreResult{}
+ f(&result)
+ storeChannel <- result
+ close(storeChannel)
+ }()
+ return storeChannel
+}
+
func Must(sc StoreChannel) interface{} {
r := <-sc
if r.Err != nil {