cherrySync

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 2 Imported by: 3

Documentation

Overview

Package cherrySync cherrySync file from https://github.com/beego/beego/blob/develop/core/utils/safemap.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limit added in v1.1.22

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

Limit controls the concurrent requests.

func NewLimit added in v1.1.22

func NewLimit(n int) Limit

NewLimit creates a Limit that can borrow n elements from it concurrently.

func (Limit) Borrow added in v1.1.22

func (l Limit) Borrow()

Borrow borrows an element from Limit in blocking mode.

func (Limit) Return added in v1.1.22

func (l Limit) Return() error

Return returns the borrowed resource, returns error only if returned more than borrowed.

func (Limit) TryBorrow added in v1.1.22

func (l Limit) TryBorrow() bool

TryBorrow tries to borrow an element from Limit, in non-blocking mode. If success, true returned, false for otherwise.

type WaitGroup

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

WaitGroup 封装 sync.WaitGroup,提供更简单的 API

func (*WaitGroup) Add

func (wg *WaitGroup) Add(fn func())

Add 添加一个非阻塞的任务,任务在新的 Go 程执行

func (*WaitGroup) Wait

func (wg *WaitGroup) Wait()

Wait 等待所有任务执行完成

Jump to

Keyboard shortcuts

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