lock

package
v0.0.0-...-c04dacf Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Locker

type Locker interface {
	Lock()
	Unlock()
}

type TicketLock

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

a ticket lock implementation acts as a spinlock and insures goroutines complete in the order they called the lock in this helps avoid starvation of goroutines

func NewTicketLock

func NewTicketLock() *TicketLock

creates a new ticketLock starting at ticket 0

func (*TicketLock) Lock

func (tl *TicketLock) Lock()

waits until the goroutine's ticket equals the next ticket to be served

func (*TicketLock) Unlock

func (tl *TicketLock) Unlock()

signals a completion of a ticket and makes the lock available for the next ticket

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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