Sha256: 31c37a007b9988889e574b0fb4e3f0c73815a9bff61da90704e15fa7406e27f1

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'thread'
#if false
class Thread
  
  unless method_defined?(:oldInit)
  
    alias :oldInit :initialize
    @@startTraces={}
    @@startTraces[Thread.current]=["MAINTHREAD"]

    
    def initialize(*p,&b)
      @@startTraces||={}
      @@crashTraces||={}
      @@crashError||={}
      @@startTraces[self]=["NOT INITED"]
      mcaller=caller
      oldInit(*p) {|*args|
        @@startTraces[Thread.current]=mcaller
        begin
          b.call(*args)
        rescue Object=>e
          @@crashTraces[self]=e.backtrace
          #pp e,e.backtrace
        end
        }
    end
    
    def fork(*p)
      raise "FORK"
      
    end
    
    
    def stacktrace?
      @@startTraces[self]
    end
    def crashtrace?
      @@crashTraces[self]
    end
    def crashtrace
      @@crashTraces[self]
    end
    
    def stacktrace(clean=true)
      if @@startTraces[self]
        @@startTraces[self].select{|line|not line=~/rspec/}+[self]+keys.map{|k|[k,self[k]]}
      else
        ["STACKTRACE FOR Thread #{self.inspect} not available!",keys]
      end
    end
    
    
    def others
      Thread.list-[self]
    end
  end
end


#end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appswarm-0.0.1 lib/appswarm/tools/thread_tool.rb