Package org.threadly.concurrent
Class UnfairExecutor.TaskHashXorTimeStripeGenerator
- java.lang.Object
-
- org.threadly.concurrent.UnfairExecutor.TaskHashXorTimeStripeGenerator
-
- All Implemented Interfaces:
UnfairExecutor.TaskStripeGenerator
- Enclosing class:
- UnfairExecutor
public static class UnfairExecutor.TaskHashXorTimeStripeGenerator extends java.lang.Object implements UnfairExecutor.TaskStripeGenerator
Generator which will determine the task stripe by using the identity hash of the runnable andClock.lastKnownTimeNanos()
. This is the fastest built in option, however submissions of the same task many times without the clock being updated can result in a single thread being unfairly burdened. Because of that it is highly recommended to over-size your pool if you are using this distributor.A possibly more fair, but slower stripe generator would be
UnfairExecutor.AtomicStripeGenerator
.This class should not be constructed, instead it should be provided via the static function
instance()
.- Since:
- 4.5.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getStripe(java.lang.Runnable task)
Generate an identifier for the stripe to distribute the task on to.static UnfairExecutor.TaskHashXorTimeStripeGenerator
instance()
Provides an instance which can be provided into the constructor ofUnfairExecutor
.
-
-
-
Method Detail
-
instance
public static UnfairExecutor.TaskHashXorTimeStripeGenerator instance()
Provides an instance which can be provided into the constructor ofUnfairExecutor
.- Returns:
- TaskHashXorTimeStripeGenerator instance
-
getStripe
public long getStripe(java.lang.Runnable task)
Description copied from interface:UnfairExecutor.TaskStripeGenerator
Generate an identifier for the stripe to distribute the task on to.- Specified by:
getStripe
in interfaceUnfairExecutor.TaskStripeGenerator
- Parameters:
task
- Task which can be used for referencing in determining the stripe- Returns:
- Any positive or negative long value to represent the stripe
-
-