com.hazelcast.util.concurrent

## Class BackoffIdleStrategy

- java.lang.Object
- - com.hazelcast.util.concurrent.BackoffIdleStrategy

- All Implemented Interfaces:
    IdleStrategy

      public class BackoffIdleStrategy
      extends Object
      implements IdleStrategy

  Idling strategy for threads when they have no work to do.

  Spin for maxSpins, then `Thread.yield()` for maxYields, then `LockSupport.parkNanos(long)` on an exponential backoff to maxParkPeriodNs

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BackoffIdleStrategy(long maxSpins, long maxYields, long minParkPeriodNs, long maxParkPeriodNs)` Create a set of state tracking idle behavior

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static BackoffIdleStrategy` | `createBackoffIdleStrategy(String config)` Creates a new BackoffIdleStrategy.
    `boolean` | `idle(long n)` Perform current idle strategy's step n.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BackoffIdleStrategy

          public BackoffIdleStrategy(long maxSpins,
                                     long maxYields,
                                     long minParkPeriodNs,
                                     long maxParkPeriodNs)

      Create a set of state tracking idle behavior
      Parameters:
        `maxSpins` - to perform before moving to `Thread.yield()`
        `maxYields` - to perform before moving to `LockSupport.parkNanos(long)`
        `minParkPeriodNs` - to use when initiating parking
        `maxParkPeriodNs` - to use when parking

  - ### Method Detail

    - #### idle

          public boolean idle(long n)

      Perform current idle strategy's step n.
      Specified by:
        `idle` in interface `IdleStrategy`
      Parameters:
        `n` - number of times this method has been previously called with no intervening work done.
      Returns:
        whether the strategy has reached the longest pause time.

    - #### createBackoffIdleStrategy

          public static BackoffIdleStrategy createBackoffIdleStrategy(String config)

      Creates a new BackoffIdleStrategy.

Copyright © 2018. All rights reserved.