3 Star 2 Fork 1

Gitee 极速下载 / codis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/CodisLabs/codis
克隆/下载
future.go 614 Bytes
一键复制 编辑 原始数据 按行查看 历史
spinlock 提交于 2016-01-17 23:14 . Update, license
// Copyright 2016 CodisLabs. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.
package sync2
import "sync"
type Future struct {
sync.Mutex
wait sync.WaitGroup
vmap map[string]interface{}
}
func (f *Future) lazyInit() {
if f.vmap == nil {
f.vmap = make(map[string]interface{})
}
}
func (f *Future) Add() {
f.wait.Add(1)
}
func (f *Future) Done(key string, val interface{}) {
f.Lock()
defer f.Unlock()
f.lazyInit()
f.vmap[key] = val
f.wait.Done()
}
func (f *Future) Wait() map[string]interface{} {
f.wait.Wait()
f.Lock()
defer f.Unlock()
f.lazyInit()
return f.vmap
}
1
https://gitee.com/mirrors/codis.git
git@gitee.com:mirrors/codis.git
mirrors
codis
codis
de1ad026e329

搜索帮助