utmost

package module
v0.0.0-...-b1c639d Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2019 License: MIT Imports: 1 Imported by: 0

README

go-utmost

limit the number of simultaneous goroutines, with some observability.

GoDoc Build Status codecov Go Report Card

Documentation

Overview

Package utmost lets you limit the number of simultaneous goroutines, with some observability.

Index

Constants

View Source
const (
	// DefaultUtmost is used if you ask a negative limit
	DefaultUtmost = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type TicketsMachine

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

TicketsMachine is our base type

func New

func New(limit int) *TicketsMachine

New returns a initialized *TicketsMachine

func (*TicketsMachine) Dispensed

func (t *TicketsMachine) Dispensed() int

Dispensed returns the total number of dispensed tickets

func (*TicketsMachine) Go

func (t *TicketsMachine) Go(goroutine func())

Go executes your function as a goroutine, and blocks awaiting a free ticket if needed

func (*TicketsMachine) InUse

func (t *TicketsMachine) InUse() int

InUse returns the currently used tickets

func (*TicketsMachine) Limit

func (t *TicketsMachine) Limit() int

Limit returns the limit of simultaneous dispensed tickets

func (*TicketsMachine) MaxInUse

func (t *TicketsMachine) MaxInUse() int

MaxInUse returns the max simultaneous used tickets

func (*TicketsMachine) Wait

func (t *TicketsMachine) Wait()

Wait blocks until the WaitGroup counter is zero.

Jump to

Keyboard shortcuts

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