当前位置: 首页>>代码示例>>Golang>>正文


Golang Pool.Close方法代码示例

本文整理汇总了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
}
开发者ID:itchio,项目名称:wharf,代码行数:26,代码来源:permissions.go

示例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
				}
			}
		}
	}
}
开发者ID:itchio,项目名称:butler,代码行数:35,代码来源:healer_archive.go

示例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
}
开发者ID:itchio,项目名称:wharf,代码行数:42,代码来源:sign.go


注:本文中的github.com/itchio/wharf/wsync.Pool.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。