1 Star 0 Fork 1

梁俊 / rpc2

forked from mirrors_cenkalti / rpc2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
state.go 413 Bytes
一键复制 编辑 原始数据 按行查看 历史
Cenk Alti 提交于 2015-06-04 10:12 . associate State variable with Client
package rpc2
import "sync"
type State struct {
store map[string]interface{}
m sync.RWMutex
}
func NewState() *State {
return &State{store: make(map[string]interface{})}
}
func (s *State) Get(key string) (value interface{}, ok bool) {
s.m.RLock()
value, ok = s.store[key]
s.m.RUnlock()
return
}
func (s *State) Set(key string, value interface{}) {
s.m.Lock()
s.store[key] = value
s.m.Unlock()
}
1
https://gitee.com/liang-jun1125/rpc2.git
git@gitee.com:liang-jun1125/rpc2.git
liang-jun1125
rpc2
rpc2
v1.0.0

搜索帮助