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, line 237 def initialize(&block) ::Kernel.raise Error, "must provide block for an async job" unless block @block = block 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, line 266 def __value unless defined?(@value) __get_value end if @value.is_a?(WrappedException) ::Kernel.raise @value end @value 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, line 243 def method_missing(*args, &block) __value.public_send(*args, &block) 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, line 251 def respond_to_missing?(*args) __value.respond_to?(*args) 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, line 282 def __run_block # This may not catch concurrent calls (unless surrounded by a mutex), but # it's not worth trying to protect against that. It's enough to just check for # multiple non-concurrent calls. ::Kernel.raise Error, "Cannot run async block multiple times" unless block = @block @block = nil begin block.call rescue ::Exception => e WrappedException.new(e) end end