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 (*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.
Click to show internal directories.
Click to hide internal directories.