代码拉取完成,页面将自动刷新
Get
method to cfgfile.Registry
(#5581)
package cfgfile
import "sync"
// Registry holds a list of Runners mapped by their unique hashes
type Registry struct {
sync.RWMutex
List map[uint64]Runner
}
// NewRegistry returns a new empty Registry
func NewRegistry() *Registry {
return &Registry{
List: map[uint64]Runner{},
}
}
// Add the given Runner to the list, indexed by a hash
func (r *Registry) Add(hash uint64, m Runner) {
r.Lock()
defer r.Unlock()
r.List[hash] = m
}
// Remove the Runner with the given hash from the list
func (r *Registry) Remove(hash uint64) {
r.Lock()
defer r.Unlock()
delete(r.List, hash)
}
// Has returns true if there is a Runner with the given hash
func (r *Registry) Has(hash uint64) bool {
r.RLock()
defer r.RUnlock()
_, ok := r.List[hash]
return ok
}
// Get returns the Runner with the given hash, or nil if it doesn't exist
func (r *Registry) Get(hash uint64) Runner {
r.RLock()
defer r.RUnlock()
return r.List[hash]
}
// CopyList returns a static copy of the Runners map
func (r *Registry) CopyList() map[uint64]Runner {
r.RLock()
defer r.RUnlock()
// Create a copy of the list
list := map[uint64]Runner{}
for k, v := range r.List {
list[k] = v
}
return list
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。