Documentation
¶
Overview ¶
Package sync provides sync primitives.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FallibleOnce ¶ added in v0.2502.0
type FallibleOnce struct {
// contains filtered or unexported fields
}
FallibleOnce is similar to `sync.Once` but supports returning an error and retrying in case the function does not succeed.
func (*FallibleOnce) Do ¶ added in v0.2502.0
func (o *FallibleOnce) Do(f func() error) error
Do executes the given function exactly once, unless the function returns an error. In case an error is returned, the function will be executed again on the next invocation of `Do`.
func (*FallibleOnce) Done ¶ added in v0.2502.0
func (o *FallibleOnce) Done() bool
Done returns true if the function has been executed successfully without error.
If it returns false, the function's execution status is uncertain. The function may have been executed successfully, may be in progress, or may not have been executed successfully at all.
type One ¶
type One interface {
// TryStart starts the function iff no other is running.
TryStart(func(context.Context)) bool
// TryStop stops the running function, if any. This method blocks until
// the function finishes its work.
TryStop() bool
// IsRunning returns true iff the function is running.
IsRunning() bool
}
One is an object that will allow to run only one function at a time.