class Sequel::Database::AsyncThreadPool::BaseProxy

Base proxy object class for jobs processed by async threads and the returned result.

Public Class Methods

new(&block) click to toggle source

Store a block that returns the result when called.

    # File lib/sequel/extensions/async_thread_pool.rb
231 def initialize(&block)
232   ::Kernel.raise Error, "must provide block for an async job" unless block
233   @block = block
234 end

Public Instance Methods

__value() click to toggle source

Wait for the value to be loaded if it hasn’t already been loaded. If the code to load the return value raised an exception that was wrapped, reraise the exception.

    # File lib/sequel/extensions/async_thread_pool.rb
260 def __value
261   unless defined?(@value)
262     __get_value
263   end
264 
265   if @value.is_a?(WrappedException)
266     ::Kernel.raise @value
267   end
268 
269   @value
270 end
method_missing(*args, &block) click to toggle source

Pass all method calls to the returned result.

    # File lib/sequel/extensions/async_thread_pool.rb
237 def method_missing(*args, &block)
238   __value.public_send(*args, &block)
239 end
respond_to_missing?(*args) click to toggle source

Delegate respond_to? calls to the returned result.

    # File lib/sequel/extensions/async_thread_pool.rb
245 def respond_to_missing?(*args)
246   __value.respond_to?(*args)
247 end

Private Instance Methods

__run_block() click to toggle source

Run the block and return the block value. If the block call raises an exception, wrap the exception.

    # File lib/sequel/extensions/async_thread_pool.rb
276 def __run_block
277   # This may not catch concurrent calls (unless surrounded by a mutex), but
278   # it's not worth trying to protect against that.  It's enough to just check for
279   # multiple non-concurrent calls.
280   ::Kernel.raise Error, "Cannot run async block multiple times" unless block = @block
281 
282   @block = nil
283 
284   begin
285     block.call
286   rescue ::Exception => e
287     WrappedException.new(e)
288   end
289 end