Documentation ¶
Overview ¶
Package tdsync contains some useful synchronization utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CancellableGroup ¶
type CancellableGroup struct {
// contains filtered or unexported fields
}
CancellableGroup is simple wrapper around errgroup.Group to make group cancellation easier. Unlike WaitGroup and errgroup.Group this is not allowed to use zero value.
func NewCancellableGroup ¶
func NewCancellableGroup(parent context.Context) *CancellableGroup
NewCancellableGroup creates new CancellableGroup.
func (*CancellableGroup) Cancel ¶
func (g *CancellableGroup) Cancel()
Cancel cancels all goroutines in group.
Note: context cancellation error will be returned by Wait().
func (*CancellableGroup) Go ¶
func (g *CancellableGroup) Go(f func(groupCtx context.Context) error)
Go calls the given function in a new goroutine.
The first call to return a non-nil error cancels the group; its error will be returned by Wait.
func (*CancellableGroup) Wait ¶
func (g *CancellableGroup) Wait() error
Wait blocks until all function calls from the Go method have returned, then returns the first non-nil error (if any) from them.
type LogGroup ¶
type LogGroup struct {
// contains filtered or unexported fields
}
LogGroup is simple wrapper around CancellableGroup to log task state. Unlike WaitGroup and errgroup.Group this is not allowed to use zero value.
func NewLogGroup ¶
NewLogGroup creates new LogGroup.
func (*LogGroup) Cancel ¶ added in v0.21.2
func (g *LogGroup) Cancel()
Cancel cancels all goroutines in group.
Note: context cancellation error will be returned by Wait().
type Ready ¶
type Ready struct {
// contains filtered or unexported fields
}
Ready is simple signal primitive which sends signal once. This is not allowed to use zero value.
type ResetReady ¶
type ResetReady struct {
// contains filtered or unexported fields
}
ResetReady is like Ready, but can be Reset.
func (*ResetReady) Ready ¶
func (r *ResetReady) Ready() <-chan struct{}
Ready returns waiting channel.
func (*ResetReady) Signal ¶
func (r *ResetReady) Signal()
Signal sends ready signal. Can be called multiple times.