Class: Rex::ThreadFactory
- Inherits:
-
Object
- Object
- Rex::ThreadFactory
- Defined in:
- lib/rex/thread_factory.rb
Overview
This class provides a wrapper around Thread.new that can provide additional features if a corresponding thread provider is set.
Constant Summary collapse
- @@provider =
nil
Class Method Summary collapse
Class Method Details
.provider=(val) ⇒ Object
15 16 17 |
# File 'lib/rex/thread_factory.rb', line 15 def self.provider=(val) @@provider = val end |
.spawn(name, crit, *args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rex/thread_factory.rb', line 19 def self.spawn(name, crit, *args, &block) if @@provider if block return @@provider.spawn(name, crit, *args){ |*args_copy| block.call(*args_copy) } else return @@provider.spawn(name, crit, *args) end else t = nil if block t = ::Thread.new(*args){ |*args_copy| block.call(*args_copy) } else t = ::Thread.new(*args) end t[:tm_name] = name t[:tm_crit] = crit t[:tm_time] = Time.now t[:tm_call] = caller return t end end |