/** * Get the current limiter in a thread safe way. If the limiter does not exist it will be * created in a thread safe way. In addition the limiters handling task count will be * incremented in expectation for execution. If not accessing for execution * {@link #currentLimiters} should just be accessed directly. * * @param taskKey Key used to identify execution limiter * @return Container with limiter and associated state data */ protected LimiterContainer getLimiterContainer(Object taskKey) { return currentLimiters.compute(taskKey, (k, v) -> { if (v == null) { v = new LimiterContainer(taskKey, makeLimiter(subPoolName + (addKeyToThreadName ? taskKey.toString() : ""))); } // must increment while in compute to prevent early removal v.handlingTasks.incrementAndGet(); return v; }); }
/** * Get the current limiter in a thread safe way. If the limiter does not exist it will be * created in a thread safe way. In addition the limiters handling task count will be * incremented in expectation for execution. If not accessing for execution * {@link #currentLimiters} should just be accessed directly. * * @param taskKey Key used to identify execution limiter * @return Container with limiter and associated state data */ protected LimiterContainer getLimiterContainer(Object taskKey) { return currentLimiters.compute(taskKey, (k, v) -> { if (v == null) { v = new LimiterContainer(taskKey, makeLimiter(subPoolName + (addKeyToThreadName ? taskKey.toString() : ""))); } // must increment while in compute to prevent early removal v.handlingTasks.incrementAndGet(); return v; }); }