本文整理汇总了Golang中github.com/attic-labs/noms/types.ValueReader类的典型用法代码示例。如果您正苦于以下问题:Golang ValueReader类的具体用法?Golang ValueReader怎么用?Golang ValueReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ValueReader类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getDeps
// getDeps reads the types.Package objects referred to by depRefs from vr and returns a map of ref: PackageDef.
func getDeps(deps []ref.Ref, vr types.ValueReader) map[ref.Ref]types.Package {
depsMap := map[ref.Ref]types.Package{}
for _, depRef := range deps {
v := vr.ReadValue(depRef)
d.Chk.NotNil(v, "Importing package by ref %s failed.", depRef.String())
depsMap[depRef] = v.(types.Package)
}
return depsMap
}
示例2: generateDepCode
func generateDepCode(packageName, outDir string, written map[string]bool, p types.Package, localPkgs refSet, vr types.ValueReader) depsMap {
deps := depsMap{}
for _, r := range p.Dependencies() {
p := vr.ReadValue(r).(types.Package)
pDeps := generateDepCode(packageName, outDir, written, p, localPkgs, vr)
tag := code.ToTag(p.Ref())
parsed := pkg.Parsed{Package: p, Name: packageName}
if !localPkgs[parsed.Ref()] {
generateAndEmit(tag, filepath.Join(outDir, tag+"."+*outputLang), written, pDeps, parsed)
localPkgs[parsed.Ref()] = true
}
for depRef, dep := range pDeps {
deps[depRef] = dep
}
deps[r] = p
}
return deps
}
示例3: doChunkWalkP
func doChunkWalkP(r ref.Ref, vr types.ValueReader, callback SomeChunksCallback, concurrency int) {
rq := newRefQueue()
wg := sync.WaitGroup{}
mu := sync.Mutex{}
visitedRefs := map[ref.Ref]bool{}
walkChunk := func(r ref.Ref) {
defer wg.Done()
mu.Lock()
visited := visitedRefs[r]
visitedRefs[r] = true
mu.Unlock()
if visited || callback(r) {
return
}
v := vr.ReadValue(r)
for _, r1 := range v.Chunks() {
wg.Add(1)
rq.tail() <- r1.TargetRef()
}
}
iter := func() {
for r := range rq.head() {
walkChunk(r)
}
}
for i := 0; i < concurrency; i++ {
go iter()
}
wg.Add(1)
rq.tail() <- r
wg.Wait()
rq.close()
}
示例4: TargetValue
func (r RefOfRemotePhoto) TargetValue(vr types.ValueReader) RemotePhoto {
return vr.ReadValue(r.target).(RemotePhoto)
}
示例5: TargetValue
func (r RefOfCompany) TargetValue(vr types.ValueReader) Company {
return vr.ReadValue(r.target).(Company)
}
示例6: TargetValue
func (r RefOfFloat32) TargetValue(vr types.ValueReader) float32 {
return float32(vr.ReadValue(r.target).(types.Float32))
}
示例7: TargetValue
func (r RefOfKey) TargetValue(vr types.ValueReader) Key {
return vr.ReadValue(r.target).(Key)
}
示例8: TargetValue
func (r RefOfAlbum) TargetValue(vr types.ValueReader) Album {
return vr.ReadValue(r.target).(Album)
}
示例9: TargetValue
func (r RefOfCommit) TargetValue(vr types.ValueReader) Commit {
return vr.ReadValue(r.target).(Commit)
}
示例10: TargetValue
func (r RefOfListOfPitch) TargetValue(vr types.ValueReader) ListOfPitch {
return vr.ReadValue(r.target).(ListOfPitch)
}
示例11: doTreeWalkP
func doTreeWalkP(v types.Value, vr types.ValueReader, cb SomeCallback, concurrency int) {
rq := newRefQueue()
f := newFailure()
visited := map[ref.Ref]bool{}
mu := sync.Mutex{}
wg := sync.WaitGroup{}
var processVal func(v types.Value)
processVal = func(v types.Value) {
if cb(v) {
return
}
if r, ok := v.(types.RefBase); ok {
wg.Add(1)
rq.tail() <- r.TargetRef()
} else {
for _, c := range v.ChildValues() {
processVal(c)
}
}
}
processRef := func(r ref.Ref) {
defer wg.Done()
mu.Lock()
skip := visited[r]
visited[r] = true
mu.Unlock()
if skip || f.didFail() {
return
}
v := vr.ReadValue(r)
if v == nil {
f.fail(fmt.Errorf("Attempt to copy absent ref:%s", r.String()))
return
}
processVal(v)
}
iter := func() {
for r := range rq.head() {
processRef(r)
}
}
for i := 0; i < concurrency; i++ {
go iter()
}
processVal(v)
wg.Wait()
rq.close()
f.checkNotFailed()
}