<commit_before>package org.threadly.concurrent;

import java.util.concurrent.atomic.AtomicInteger;

import org.threadly.util.Clock;

/**
 * This is a small wrapper class for Clock to avoid updating for bulk calls.
 * This is primarily useful for the {@link PriorityScheduledExecutor} when it needs to 
 * do a binary search in a list of delayed items, or sort those delayed items.
 * There is no reason to make a system call for each item, so we just pause getting
 * accurate time for those fast but frequent operations.
 * 
 * All the functions in this class are protected because it is not intended to be used 
 * outside of this package.  This is a utility class that must be handled carefully, 
 * using it incorrectly could have serious impacts on other classes which depend on it.
 * 
 * @author jent - <NAME>
 */
public class ClockWrapper {
  private static AtomicInteger requestsToStopUpdatingTime = new AtomicInteger();
  
  private ClockWrapper() {
    // don't construct
  }
  
  /**
   * A call here causes getAccurateTime to use the last known time.
   */
  protected static void stopForcingUpdate() {
    requestsToStopUpdatingTime.incrementAndGet();
  }
  
  /**
   * This resumes updating the clock for calls to getAccurateTime.
   */
  protected static void resumeForcingUpdate() {
    int newVal = requestsToStopUpdatingTime.decrementAndGet();<commit_msg>This can be final<commit_after>package org.threadly.concurrent;

import java.util.concurrent.atomic.AtomicInteger;

import org.threadly.util.Clock;

/**
 * This is a small wrapper class for Clock to avoid updating for bulk calls.
 * This is primarily useful for the {@link PriorityScheduledExecutor} when it needs to 
 * do a binary search in a list of delayed items, or sort those delayed items.
 * There is no reason to make a system call for each item, so we just pause getting
 * accurate time for those fast but frequent operations.
 * 
 * All the functions in this class are protected because it is not intended to be used 
 * outside of this package.  This is a utility class that must be handled carefully, 
 * using it incorrectly could have serious impacts on other classes which depend on it.
 * 
 * @author jent - Mike Jensen
 */
public class ClockWrapper {
  private static final AtomicInteger requestsToStopUpdatingTime = new AtomicInteger();
  
  private ClockWrapper() {
    // don't construct
  }
  
  /**
   * A call here causes getAccurateTime to use the last known time.
   */
  protected static void stopForcingUpdate() {
    requestsToStopUpdatingTime.incrementAndGet();
  }
  
  /**
   * This resumes updating the clock for calls to getAccurateTime.
   */
  protected static void resumeForcingUpdate() {
    int newVal = requestsToStopUpdatingTime.decrementAndGet();
{'fraction_non_alphanumeric': 0.06297502714440825, 'fraction_numerical': 0.0, 'mean_word_length': 3.732876712328767, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4503573', 'n_tokens_mistral': 737, 'n_tokens_neox': 705, 'n_words': 332}