Class: Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/appswarm/tools/thread_tool.rb

Overview

if false

Constant Summary collapse

@@startTraces =
{}

Instance Method Summary collapse

Constructor Details

#initialize(*p, &b) ⇒ Thread

Returns a new instance of Thread.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/appswarm/tools/thread_tool.rb', line 12

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

Instance Method Details

#crashtraceObject



41
42
43
# File 'lib/appswarm/tools/thread_tool.rb', line 41

def crashtrace
  @@crashTraces[self]
end

#crashtrace?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/appswarm/tools/thread_tool.rb', line 38

def crashtrace?
  @@crashTraces[self]
end

#fork(*p) ⇒ Object



29
30
31
32
# File 'lib/appswarm/tools/thread_tool.rb', line 29

def fork(*p)
  raise "FORK"
  
end

#oldInitObject



7
# File 'lib/appswarm/tools/thread_tool.rb', line 7

alias :oldInit :initialize

#othersObject



54
55
56
# File 'lib/appswarm/tools/thread_tool.rb', line 54

def others
  Thread.list-[self]
end

#stacktrace(clean = true) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/appswarm/tools/thread_tool.rb', line 45

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

#stacktrace?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/appswarm/tools/thread_tool.rb', line 35

def stacktrace?
  @@startTraces[self]
end