synchain

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Synchain

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

Synchain is a helper to implement internal sequential execution of parallel jobs

NOTE: Init MUST be called before calling other methods

func NewSynchain

func NewSynchain() (ret *Synchain)

NewSynchain creates a new Synchain

func (*Synchain) Cancel

func (sg *Synchain) Cancel(err error)

Cancel the sync group with error, wakeup all waiting goroutines

func (*Synchain) Done

func (sg *Synchain) Done()

Done is sync.WaitGroup.Done

func (*Synchain) Err

func (sg *Synchain) Err() error

Err returns the last error stored when Cancel called

func (*Synchain) Go

func (sg *Synchain) Go(fn func(t Ticket) error)

Go spawns a new goroutine in the sync group, user func MUST call Lock with the ticket passed

on error return of user func, it calls Cancel and Done, otherwise, calls Unlock and Done

func (*Synchain) Init

func (sg *Synchain) Init()

Init this sync group

func (*Synchain) Lock

func (sg *Synchain) Lock(t Ticket) bool

Lock waits until this job can be continued

func (*Synchain) NewTicket

func (sg *Synchain) NewTicket() (ret Ticket)

NewTicket creates a new sequence handle in this sync group

func (*Synchain) Unlock

func (sg *Synchain) Unlock(t Ticket)

Unlock wakes next waiting goroutine

func (*Synchain) Wait

func (sg *Synchain) Wait()

type Ticket

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

Ticket is the handle used to ensure sequence

Jump to

Keyboard shortcuts

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