package tdsync

Import Path
	github.com/gotd/td/internal/tdsync (on go.dev)

Dependency Relation
	imports 9 packages, and imported by 5 packages

Involved Source Files backoff.go Package tdsync contains some useful synchronization utilities. log_group.go ready.go reset_ready.go supervisor.go
Package-Level Type Names (total 6, in which 5 are exported)
/* sort exporteds by: | */
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. Cancel cancels all goroutines in group. Note: context cancellation error will be returned by Wait(). 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. Wait blocks until all function calls from the Go method have returned, then returns the first non-nil error (if any) from them. func NewCancellableGroup(parent context.Context) *CancellableGroup
LogGroup is simple wrapper around CancellableGroup to log task state. Unlike WaitGroup and errgroup.Group this is not allowed to use zero value. Cancel cancels all goroutines in group. Note: context cancellation error will be returned by Wait(). 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. SetClock sets Clock to use. Wait blocks until all function calls from the Go method have returned, then returns the first non-nil error (if any) from them. func NewLogGroup(parent context.Context, log *zap.Logger) *LogGroup
Ready is simple signal primitive which sends signal once. This is not allowed to use zero value. Ready returns waiting channel. Signal sends ready signal. Can be called multiple times. func NewReady() *Ready
ResetReady is like Ready, but can be Reset. Ready returns waiting channel. Reset resets underlying Ready. Signal sends ready signal. Can be called multiple times. func NewResetReady() *ResetReady
Supervisor is simple task group primitive to control multiple long-live tasks. Unlike Groups, Supervisor does not cancel when one task is failed. Unlike WaitGroup and errgroup.Group this is not allowed to use zero value. Cancel cancels all goroutines in group. Note: context cancellation error can be returned by Wait(). Go calls the given function in a new goroutine. Wait blocks until all function calls from the Go method have returned, then returns the first non-nil error (if any) from them. WithErrorHandler sets tasks error handler Must be called before any Go calls. func NewSupervisor(parent context.Context) *Supervisor func (*Supervisor).WithErrorHandler(h func(err error)) *Supervisor
Package-Level Functions (total 6, all are exported)
NewCancellableGroup creates new CancellableGroup. Example: g := NewCancellableGroup(ctx) g.Go(func(ctx context.Context) error { <-ctx.Done() return ctx.Err() }) g.Cancel() g.Wait()
NewLogGroup creates new LogGroup.
NewReady creates new Ready.
NewResetReady creates new ResetReady.
NewSupervisor creates new Supervisor.
SyncBackoff decorates backoff.BackOff to be thread-safe.