Sha256: 458faa31bc37cb71f5ee83af1c3c2bc17f1f931d61e17e624b8fe13bdb40b2ac

Contents?: true

Size: 727 Bytes

Versions: 57

Compression:

Stored size: 727 Bytes

Contents

#This class behaves like a normal thread - but it shows error-messages and tracebacks. Normal threads dont do that.
class Knj::Thread < Thread
  attr_accessor :data
  
  #Initializes the thread and passes any given arguments to the thread-block.
  def initialize(*args)
    raise "No block was given." unless block_given?
    
    super(*args) do
      begin
        yield(*args)
      rescue SystemExit, Interrupt
        raise
      rescue Exception => e
        print "#{Knj::Errors.error_str(e)}\n\n"
      end
    end
    
    @data = {}
  end
  
  #Returns a key from the data-hash.
  def [](key)
    return @data[key]
  end
  
  #Sets a key on the data-hash.
  def []=(key, value)
    return @data[key] = value
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
knjrbfw-0.0.116 lib/knj/thread.rb
knjrbfw-0.0.115 lib/knj/thread.rb
knjrbfw-0.0.114 lib/knj/thread.rb
knjrbfw-0.0.113 lib/knj/thread.rb
knjrbfw-0.0.111 lib/knj/thread.rb
knjrbfw-0.0.110 lib/knj/thread.rb
knjrbfw-0.0.109 lib/knj/thread.rb
knjrbfw-0.0.108 lib/knj/thread.rb
knjrbfw-0.0.107 lib/knj/thread.rb
knjrbfw-0.0.105 lib/knj/thread.rb
knjrbfw-0.0.104 lib/knj/thread.rb
knjrbfw-0.0.103 lib/knj/thread.rb
knjrbfw-0.0.102 lib/knj/thread.rb
knjrbfw-0.0.101 lib/knj/thread.rb
knjrbfw-0.0.100 lib/knj/thread.rb
knjrbfw-0.0.99 lib/knj/thread.rb
knjrbfw-0.0.98 lib/knj/thread.rb
knjrbfw-0.0.97 lib/knj/thread.rb
knjrbfw-0.0.96 lib/knj/thread.rb
knjrbfw-0.0.95 lib/knj/thread.rb