Documentation ¶
Index ¶
Constants ¶
const DefaultMaxParkNs = int64(1 * time.Millisecond)
DefaultMaxParkNs is the default interval the strategy will park the thread will expand interval to as a max.
const DefaultMaxSpins = 10
DefaultMaxSpins is the default number of times the strategy will spin without work before going to next state.
const DefaultMaxYields = 20
DefaultMaxYields is the default number of times the strategy will yield without work before going to next state.
const DefaultMinParkNs = 1000
DefaultMinParkNs is the default interval the strategy will park the thread on entering the park state.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackoffIdleStrategy ¶
type BackoffIdleStrategy struct {
// contains filtered or unexported fields
}
BackoffIdleStrategy is an idling strategy for threads when they have no work to do. Spin for maxSpins, then yield with runtime.Gosched for maxYields, then park with time.Sleep on an exponential backoff to maxParkPeriodNs.
func NewBackoffIdleStrategy ¶
func NewBackoffIdleStrategy(maxSpins, maxYields, minParkPeriodNs, maxParkPeriodNs int64) *BackoffIdleStrategy
NewBackoffIdleStrategy returns a BackoffIdleStrategy with the given parameters.
func NewDefaultBackoffIdleStrategy ¶
func NewDefaultBackoffIdleStrategy() *BackoffIdleStrategy
NewDefaultBackoffIdleStrategy returns a BackoffIdleStrategy using DefaultMaxSpins, DefaultMaxYields, DefaultMinParkNs, and DefaultMaxParkNs.
func (*BackoffIdleStrategy) Idle ¶
func (s *BackoffIdleStrategy) Idle(workCount int)
func (*BackoffIdleStrategy) String ¶
func (s *BackoffIdleStrategy) String() string