Version: v0.0.0-...-2bde968 Latest Latest

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 3 Imported by: 0




This section is empty.


View Source
var (
	ErrInProgress = fmt.Errorf("future still in progress")
View Source
var (
	ErrReturnAll = fmt.Errorf("return all tokens")


func TempUnlock

func TempUnlock(locker sync.Locker, f func() error) error

TempUnlock unlocks the locker, runs f and returns what it returns, and re-locks after f has run.

func UnlockOnce

func UnlockOnce(locker sync.Locker) func()


type Dealer

type Dealer struct {
	// contains filtered or unexported fields

func NewDealer

func NewDealer() *Dealer

func (*Dealer) Dealing

func (dealer *Dealer) Dealing() <-chan struct{}

func (*Dealer) Get

func (dealer *Dealer) Get() (*Token, error)

func (*Dealer) Reset

func (dealer *Dealer) Reset(ctx context.Context) error


func (*Dealer) ReturnAllTokens

func (dealer *Dealer) ReturnAllTokens(ctx context.Context) error

type Finisher

type Finisher interface {
	Finish(err error)

func NewFuture

func NewFuture() Finisher

type Future

type Future interface {
	Done() <-chan struct{}
	Err() error

type Lock

type Lock struct {
	// contains filtered or unexported fields

func NewLock

func NewLock() *Lock

TODO: expand into Semaphore

func (*Lock) Lock

func (lock *Lock) Lock()

func (*Lock) LockCtx

func (lock *Lock) LockCtx(ctx context.Context) error

func (*Lock) LockTry

func (lock *Lock) LockTry() bool

func (*Lock) SafeUnlock

func (lock *Lock) SafeUnlock()

func (*Lock) Unlock

func (lock *Lock) Unlock()

type Token

type Token struct {
	// contains filtered or unexported fields

func (*Token) Done

func (token *Token) Done() <-chan struct{}

func (*Token) Return

func (token *Token) Return()

Jump to

Keyboard shortcuts

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