<commit_before>package com.socrata.datacoordinator.util

import com.socrata.datacoordinator.id.{RowVersion, RowId}

class RowDataProvider(initial: Long) {
  private var next = initial
  private var finished = false

  def allocate() = synchronized {
    if(finished) throw new IllegalStateException("Already finished")
    val result = next
    next += 1
    result
  }

  def finish(): Long = synchronized {
    finished = true
    next
  }

  def release() {}
}

class RowIdProvider(val underlying: RowDataProvider) extends AnyVal {
  def allocate() = new RowId(underlying.allocate())
}

class RowVersionProvider(val underlying: RowDataProvider) extends AnyVal {
  def allocate() = new RowVersion(underlying.allocate())
}
<commit_msg>Change RowDataProvider to use AtomicLongs instead of synchronized blocks<commit_after>package com.socrata.datacoordinator.util

import com.socrata.datacoordinator.id.{RowVersion, RowId}
import java.util.concurrent.atomic.AtomicLong

class RowDataProvider(initial: Long) {
  private val next = new AtomicLong(initial)

  def allocate(): Long = {
    while(true) {
      val result = next.get
      if(result == -1) throw new IllegalStateException("Already finished")
      if(next.compareAndSet(result, result + 1)) return result
    }
    sys.error("Can't get here")
  }

  def finish(): Long =
    next.getAndSet(-1)

  def release() {}
}

class RowIdProvider(val underlying: RowDataProvider) extends AnyVal {
  def allocate() = new RowId(underlying.allocate())
}

class RowVersionProvider(val underlying: RowDataProvider) extends AnyVal {
  def allocate() = new RowVersion(underlying.allocate())
}

{'fraction_non_alphanumeric': 0.10268948655256724, 'fraction_numerical': 0.0024449877750611247, 'mean_word_length': 4.438538205980066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '21140', 'n_tokens_mistral': 492, 'n_tokens_neox': 474, 'n_words': 129}