<commit_before>require 'rubygems'
require 'bud'

module TimeoutProto
  state do
    interface input, :interval, [] => [:minTimeout, :maxTimeout]
    interface input, :snooze, [:ok]
    interface output, :alarm, [:timeout]
  end
end

module UniformlyDistributedTimeout
  include TimeoutProto

  TIMER_INTERVAL = 0.05
  entropy = Random.new

  state do
    periodic :timer, TIMER_INTERVAL
    table :countdown, [] => [:timeRemaining] 
  end
  
  bloom do
  
    # countdown contains the amount of time remaining till the alarm "wakes_up"
    # it is reset to a random timeout if snooze is recieved
    countdown <+- (timer * countdown * interval * snooze).combos do |t, c, i, s|
        if snooze.ok == [nil]
          [countdown.timeRemaining - TIMER_INTERVAL]
        else
          [entropy.rand(i.minTimeout..i.maxTimeout)]
        end
    end
    
    # alarm sends out wake_up calls
    alarm <= countdown { |c| [:wake_up] if c.timeRemaining <= 0 }
    
  end
end<commit_msg>don't use reserved symbol names<commit_after>require 'rubygems'
require 'bud'

module TimeoutProto
  state do
    interface input, :interval, [] => [:minTimeout, :maxTimeout]
    interface input, :snooze, [:im_tired]
    interface output, :alarm, [:wake_up]
  end
end

module UniformlyDistributedTimeout
  include TimeoutProto

  TIMER_INTERVAL = 0.05
  entropy = Random.new

  state do
    periodic :timer, TIMER_INTERVAL
    table :countdown, [] => [:timeRemaining]
  end

  bloom do

    # countdown contains the amount of time remaining till the alarm "wakes_up"
    # it is reset to a random timeout if snooze is recieved
    countdown <+- (timer * countdown * interval * snooze).combos do |t, c, i, s|
        if snooze.ok == [nil]
          [countdown.timeRemaining - TIMER_INTERVAL]
        else
          [entropy.rand(i.minTimeout..i.maxTimeout)]
        end
    end

    # alarm sends out wake_up calls
    alarm <= countdown { |c| [:wake_up] if c.timeRemaining <= 0 }

  end
end
{'fraction_non_alphanumeric': 0.09700355510411376, 'fraction_numerical': 0.004062976130015236, 'mean_word_length': 2.9243027888446216, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3572066', 'n_tokens_mistral': 677, 'n_tokens_neox': 659, 'n_words': 197}