本文整理汇总了Golang中github.com/itchio/wharf/wsync.Pool.Close方法的典型用法代码示例。如果您正苦于以下问题:Golang Pool.Close方法的具体用法?Golang Pool.Close怎么用?Golang Pool.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/itchio/wharf/wsync.Pool
的用法示例。
在下文中一共展示了Pool.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: FixPermissions
func (c *Container) FixPermissions(pool wsync.Pool) error {
defer pool.Close()
buf := make([]byte, minScannedFileSize)
for index, f := range c.Files {
if f.Size < minScannedFileSize {
continue
}
r, err := pool.GetReader(int64(index))
if err != nil {
return errors.Wrap(err, 1)
}
_, err = io.ReadFull(r, buf)
if err != nil {
return errors.Wrap(err, 1)
}
if isExecutable(buf) {
f.Mode |= 0111
}
}
return nil
}
示例2: heal
func (ah *ArchiveHealer) heal(container *tlc.Container, zipReader *zip.Reader, zipSize int64,
targetPool wsync.WritablePool,
fileIndices chan int64, errs chan error, done chan bool, cancelled chan struct{}, chunkHealed chunkHealedFunc) {
var sourcePool wsync.Pool
var err error
sourcePool = zippool.New(container, zipReader)
defer sourcePool.Close()
for {
select {
case <-cancelled:
// something else stopped the healing
return
case fileIndex, ok := <-fileIndices:
if !ok {
// no more files to heal
done <- true
return
}
err = ah.healOne(sourcePool, targetPool, fileIndex, chunkHealed)
if err != nil {
select {
case <-cancelled:
// already cancelled, no need for more errors
return
case errs <- err:
return
}
}
}
}
}
示例3: ComputeSignatureToWriter
// ComputeSignatureToWriter is a variant of ComputeSignature that writes hashes
// to a callback
func ComputeSignatureToWriter(container *tlc.Container, pool wsync.Pool, consumer *state.Consumer, sigWriter wsync.SignatureWriter) error {
var err error
defer func() {
if pErr := pool.Close(); pErr != nil && err == nil {
err = errors.Wrap(pErr, 1)
}
}()
sctx := mksync()
totalBytes := container.Size
fileOffset := int64(0)
onRead := func(count int64) {
consumer.Progress(float64(fileOffset+count) / float64(totalBytes))
}
for fileIndex, f := range container.Files {
consumer.ProgressLabel(f.Path)
fileOffset = f.Offset
var reader io.Reader
reader, err = pool.GetReader(int64(fileIndex))
if err != nil {
return errors.Wrap(err, 1)
}
cr := counter.NewReaderCallback(onRead, reader)
err = sctx.CreateSignature(int64(fileIndex), cr, sigWriter)
if err != nil {
return errors.Wrap(err, 1)
}
}
if err != nil {
return errors.Wrap(err, 1)
}
return nil
}