<commit_before># "Threading"
# A hash with time => [block, block, block ...]
#
# {
#   100 => [{bla}, {blu}, {bli}],
#   1   => [{eek}]
# }
#
# When calling threading.step, eek will be executed, the others will be one step closer to zero, 99.
#
class Scheduling
  
  def initialize
    # @threads = {}
    @threads = []
  end
  
  # Adds a code block at time time.
  #
  def add time = 1, &code
    # @threads[time] ||= []
    # @threads[time] << code
    @threads << [time, code]
    @threads.sort!
  end
  
  # Does two things:
  # 1. Move one step in time.
  # 2. Execute all blocks with time 0.
  #
  # TODO Rewrite to be faster.
  #
  # FIXME - threads added while threads are handled!
  #
  def step
    @threads.collect! do |time, code|
      if time == 1
        code[]
        nil
      else
        [time-1, code]
      end<commit_msg>- schedule sorting<commit_after># "Threading"
# A hash with time => [block, block, block ...]
#
# {
#   100 => [{bla}, {blu}, {bli}],
#   1   => [{eek}]
# }
#
# When calling threading.step, eek will be executed, the others will be one step closer to zero, 99.
#
class Scheduling
  
  def initialize
    # @threads = {}
    @threads = []
  end
  
  # Adds a code block at time time.
  #
  def add time = 1, &code
    # @threads[time] ||= []
    # @threads[time] << code
    @threads << [time, code]
    # @threads.sort!
  end
  
  # Does two things:
  # 1. Move one step in time.
  # 2. Execute all blocks with time 0.
  #
  # TODO Rewrite to be faster.
  #
  # FIXME - threads added while threads are handled!
  #
  def step
    @threads.collect! do |time, code|
      if time == 1
        code[]
        nil
      else
        [time-1, code]
      end
{'fraction_non_alphanumeric': 0.14142604596346495, 'fraction_numerical': 0.014142604596346494, 'mean_word_length': 2.1155963302752294, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '196558', 'n_tokens_mistral': 621, 'n_tokens_neox': 598, 'n_words': 205}