<commit_before>require 'thread'
require 'timeout'

module Functional

  class Event

    def initialize
      @set = false
      @notifier = Queue.new
      @mutex = Mutex.new
      @waiting = 0
    end

    def set?
      return @set == true
    end

    def set
      return true if set?
      @mutex.synchronize {
        @set = true
        @waiting.times{ @notifier << :set }
        @waiting = 0
      }
    end

    def reset
      @mutex.synchronize {
        @set = false
      }
    end

    def wait(timeout = nil)
      return true if set?

      Timeout::timeout(timeout) do
        @waiting += 1
        @notifier.pop
      end
      return true

    rescue Timeout::Error
      return false
    end
  end
end
<commit_msg>Fixed timeout error in Event class.<commit_after>require 'thread'
require 'timeout'

module Functional

  class Event

    def initialize
      @set = false
      @notifier = Queue.new
      @mutex = Mutex.new
      @waiting = 0
    end

    def set?
      return @set == true
    end

    def set
      return true if set?
      @mutex.synchronize {
        @set = true
        @waiting.times{ @notifier << :set }
        @waiting = 0
      }
    end

    def reset
      @mutex.synchronize {
        @set = false
      }
    end

    def wait(timeout = nil)
      return true if set?

      if timeout.nil?
        @waiting += 1
        @notifier.pop
      else
        begin
          Timeout::timeout(timeout) do
            @waiting += 1
            @notifier.pop
          end
          return true
        rescue Timeout::Error
          return false
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07711138310893513, 'fraction_numerical': 0.004283965728274173, 'mean_word_length': 1.454954954954955, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6851728', 'n_tokens_mistral': 513, 'n_tokens_neox': 488, 'n_words': 150}