ticket

package
v2.10.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ticket

type Ticket interface {
	// Take a ticket, if no tickets remain, then will be blocked.
	// if Ticket is closed, will return non-block.
	Take()
	// Return a ticket, if Ticket is closed, will return
	Return()
	// Remainder get the number of available tickets
	Remainder() int
	// Total is the total tickets
	Total() int
	// Close Ticket, Take() will get endless non-blocking tickets
	// return error, if Ticket has been closed
	Close() error
	// Reset will create new tickets
	Reset()
}

Ticket represent limited resources to control concurrency

func New

func New(total int) Ticket

New will create a resource pool, total means count of resource in pool

Jump to

Keyboard shortcuts

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