grpool

package
v0.0.0-...-46fbbb1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2022 VMware, Inc. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GrPool

type GrPool struct {
	// contains filtered or unexported fields
}

GrPool is an implementation of Pool.

func WithContext

func WithContext(ctx context.Context) *GrPool

WithContext inits the worker GrPool with context.

func (*GrPool) Close

func (p *GrPool) Close()

Close implements Pool.

func (*GrPool) MaxQueueSize

func (p *GrPool) MaxQueueSize(size uint32) *GrPool

MaxQueueSize set the job queue size. If the job queue is full, then the related job queuing calls will be blocked.

func (*GrPool) MaxWorkers

func (p *GrPool) MaxWorkers(workers uint32) *GrPool

MaxWorkers sets the max number of concurrent workers.

func (*GrPool) Plan

func (p *GrPool) Plan(jobSize int) error

Plan the job size.

func (*GrPool) Queue

func (p *GrPool) Queue(job Job)

Queue implements Pool.

func (*GrPool) Start

func (p *GrPool) Start() Pool

func (*GrPool) Wait

func (p *GrPool) Wait() error

Wait implements Pool.

type Job

type Job func(ctx context.Context) <-chan error

Job for running in the pool.

type Pool

type Pool interface {
	// Close the pool and release resources.
	Close()
	// Plan job size.
	Plan(jobSize int) error
	// Queue job into the pool.
	Queue(job Job)
	// Wait all the jobs completed.
	Wait() error
}

Pool of running funcs concurrently.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL