<commit_before>
public prefix func ++ (group: DispatchGroup) {
  ++group.tasksRemaining
}

public prefix func -- (group: DispatchGroup) {
  if group.tasksRemaining == 0 { return }
  --group.tasksRemaining
  ++group.tasksCompleted
  if group.tasksRemaining == 0 { group.onDone?() }
}

public class DispatchGroup {

  public private(set) var tasksRemaining: Int
  
  public private(set) var tasksCompleted = 0
  
  public init (_ tasks: Int = 0) {
    tasksRemaining = tasks
  }
  
  public func done (handler: Void -> Void) {
    if tasksRemaining > 0 { onDone = handler }
    else { handler() }
  }
  
  var onDone: (Void -> Void)?
}<commit_msg>DispatchGroup is now thread-safe<commit_after>
import Dispatch

public prefix func ++ (group: DispatchGroup) {
  dispatch_group_enter(group.dispatch_group)
}

public prefix func -- (group: DispatchGroup) {
  dispatch_group_leave(group.dispatch_group)
}

public class DispatchGroup {

  public let dispatch_group = dispatch_group_create()
  
  public init (_ tasks: Int = 0) {
    for _ in 0..<tasks { ++self }
  }
  
  public func done (handler: Void -> Void) {
    dispatch_group_notify(dispatch_group, gcd.current.dispatch_queue, handler)
  }
}
{'fraction_non_alphanumeric': 0.10999160369437448, 'fraction_numerical': 0.005877413937867338, 'mean_word_length': 3.6745098039215685, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, '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': '5152001', 'n_tokens_mistral': 394, 'n_tokens_neox': 379, 'n_words': 102}