thread

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DaemonStart

func DaemonStart()

func GetGID

func GetGID() uint64

获取GOROUTINE的ID

func Go

func Go(goroutine func())

Go starts a recoverable goroutine.

func GoWithRecover

func GoWithRecover(goroutine func(), customRecover func(err interface{}))

GoWithRecover starts a recoverable goroutine using given customRecover() function.

func OperationWithRecover

func OperationWithRecover(operation func() error) func() error

OperationWithRecover wrap a backoff operation in a Recover.

Types

type Daemon

type Daemon interface {
	Done()
}

type Pool

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

Pool accept the tasks from client,it limits the total of goroutines to a given number by recycling goroutines.

func NewPool

func NewPool(size, expiry int) (*Pool, error)

NewPool generates a instance of ants pool

func (*Pool) ReSize

func (p *Pool) ReSize(size int)

动态扩容或者缩小池容量 ReSize change the capacity of this pool

func (*Pool) Submit

func (p *Pool) Submit(task functinType, str interface{}) error

Submit submit a task to pool

type Semaphore

type Semaphore struct {
	Threads chan int
	Wg      sync.WaitGroup
}

Semaphore implements the signal mechanism management

func NewSemaphore

func NewSemaphore(n int) *Semaphore

NewSemaphore returns a new semaphore

func (*Semaphore) P

func (sem *Semaphore) P()

P is a primitive operation that requests the allocation of a unit resource

func (*Semaphore) V

func (sem *Semaphore) V()

V is a primitive operation that releases a unit of resources

func (*Semaphore) Wait

func (sem *Semaphore) Wait()

Wait waits for all unit resources to be released

type Worker

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

Worker is the actual executor who runs the tasks, it starts a goroutine that accepts tasks and performs function calls.

Jump to

Keyboard shortcuts

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