Class: Thread
- Inherits:
-
Object
- Object
- Thread
- Defined in:
- lib/appswarm/tools/thread_tool.rb
Overview
if false
Constant Summary collapse
- @@startTraces =
{}
Instance Method Summary collapse
- #crashtrace ⇒ Object
- #crashtrace? ⇒ Boolean
- #fork(*p) ⇒ Object
-
#initialize(*p, &b) ⇒ Thread
constructor
A new instance of Thread.
- #oldInit ⇒ Object
- #others ⇒ Object
- #stacktrace(clean = true) ⇒ Object
- #stacktrace? ⇒ Boolean
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
#crashtrace ⇒ Object
41 42 43 |
# File 'lib/appswarm/tools/thread_tool.rb', line 41 def crashtrace @@crashTraces[self] end |
#crashtrace? ⇒ 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 |
#oldInit ⇒ Object
7 |
# File 'lib/appswarm/tools/thread_tool.rb', line 7 alias :oldInit :initialize |
#others ⇒ Object
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
35 36 37 |
# File 'lib/appswarm/tools/thread_tool.rb', line 35 def stacktrace? @@startTraces[self] end |