Class: Database::ConcurrentThreadPool::PreemptableProxy
- Defined in:
- lib/sequel/extensions/concurrent_thread_pool.rb
Overview
Preemptable proxy: calling thread runs the block if the pool hasn’t started it yet.
Instance Method Summary collapse
- #__value ⇒ Object
-
#initialize(executor, &block) ⇒ PreemptableProxy
constructor
A new instance of PreemptableProxy.
Methods inherited from BaseProxy
#method_missing, #respond_to_missing?
Constructor Details
#initialize(executor, &block) ⇒ PreemptableProxy
Returns a new instance of PreemptableProxy.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 40 def initialize(executor, &block) super() @mutex = Mutex.new @block = block @done = false @result = nil @error = nil executor.post { __run } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Database::ConcurrentThreadPool::BaseProxy
Instance Method Details
#__value ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 52 def __value error, result = @mutex.synchronize do __execute unless @done [@error, @result] end ::Kernel.raise error if error result end |