Class: Upfluence::Thread
- Inherits:
- 
      Thread
      
        - Object
- Thread
- Upfluence::Thread
 
- Defined in:
- lib/upfluence/thread.rb
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #initialize(**opts, &block)  ⇒ Thread 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Thread. 
Constructor Details
#initialize(**opts, &block) ⇒ Thread
Returns a new instance of Thread.
| 5 6 7 8 9 10 11 12 13 14 | # File 'lib/upfluence/thread.rb', line 5 def initialize(**opts, &block) thr = self.class.current wrappers = self.class.wrappers.reject { |k, _| opts.key?(k) && !opts[k] }.values super do wrappers.reduce(block) do |acc, wrapper| Proc.new { wrapper.wrap_thread(thr, acc) } end.call end end | 
Class Method Details
.register_wrapper(name, klass) ⇒ Object
| 21 22 23 24 | # File 'lib/upfluence/thread.rb', line 21 def register_wrapper(name, klass) @wrappers ||= {} @wrappers[name] = klass end | 
.wrappers ⇒ Object
| 17 18 19 | # File 'lib/upfluence/thread.rb', line 17 def wrappers @wrappers || {} end |