Documentation
¶
Overview ¶
* Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
Index ¶
- func DetermineContextError(ctx context.Context) error
- func Parallelise(argList interface{}, action func(arg interface{}) (interface{}, error), ...) (results interface{}, err error)
- func RunActionWithParallelCheck(ctx context.Context, action func(ctx context.Context) error, ...) error
- func RunActionWithTimeout(blockingAction func(stop chan bool) error, timeout time.Duration) (err error)
- func RunActionWithTimeoutAndCancelStore(ctx context.Context, timeout time.Duration, store *CancelFunctionStore, ...) error
- func RunActionWithTimeoutAndContext(ctx context.Context, timeout time.Duration, ...) error
- func Schedule(ctx context.Context, period time.Duration, offset time.Duration, ...)
- func SleepWithContext(ctx context.Context, delay time.Duration)
- func SleepWithInterruption(stop chan bool, delay time.Duration)
- type CancelFunctionStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetermineContextError ¶
Determines what the context error is if any.
func Parallelise ¶
func Parallelise(argList interface{}, action func(arg interface{}) (interface{}, error), resultType reflect.Type) (results interface{}, err error)
Parallelises an action over as many goroutines as specified by the argList and retrieves all the results when all the goroutines are done.
func RunActionWithParallelCheck ¶
func RunActionWithParallelCheck(ctx context.Context, action func(ctx context.Context) error, checkAction func(ctx context.Context) bool, checkPeriod time.Duration) error
Runs an action with a check in parallel The function performing the check should return true if the check was favorable; false otherwise. If the check did not have the expected result and the whole function would be cancelled.
func RunActionWithTimeout ¶
func RunActionWithTimeout(blockingAction func(stop chan bool) error, timeout time.Duration) (err error)
Runs an action with timeout
func RunActionWithTimeoutAndCancelStore ¶
func RunActionWithTimeoutAndCancelStore(ctx context.Context, timeout time.Duration, store *CancelFunctionStore, blockingAction func(context.Context) error) error
Runs an action with timeout
func RunActionWithTimeoutAndContext ¶
func RunActionWithTimeoutAndContext(ctx context.Context, timeout time.Duration, blockingAction func(context.Context) error) error
Runs an action with timeout blockingAction's context will be cancelled on exit.
func SleepWithContext ¶
Similar to time.Sleep() but also responding to context cancellation instead of blocking for the whole length of time.
func SleepWithInterruption ¶
Similar to time.Sleep() but also interrupting when requested instead of blocking for the whole length of time.
Types ¶
type CancelFunctionStore ¶
type CancelFunctionStore struct {
// contains filtered or unexported fields
}
func NewCancelFunctionsStore ¶
func NewCancelFunctionsStore() *CancelFunctionStore
func (*CancelFunctionStore) Cancel ¶
func (s *CancelFunctionStore) Cancel()
func (*CancelFunctionStore) Len ¶
func (s *CancelFunctionStore) Len() int
func (*CancelFunctionStore) RegisterCancelFunction ¶
func (s *CancelFunctionStore) RegisterCancelFunction(cancel ...context.CancelFunc)