class Sequel::Database::AsyncThreadPool::BaseProxy
Base proxy object class for jobs processed by async threads and the returned result.
Public Class Methods
Source
# File lib/sequel/extensions/async_thread_pool.rb 238 def initialize(&block) 239 ::Kernel.raise Error, "must provide block for an async job" unless block 240 @block = block 241 end
Store a block that returns the result when called.
Public Instance Methods
Source
# File lib/sequel/extensions/async_thread_pool.rb 267 def __value 268 unless defined?(@value) 269 __get_value 270 end 271 272 if @value.is_a?(WrappedException) 273 ::Kernel.raise @value 274 end 275 276 @value 277 end
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.
Source
# File lib/sequel/extensions/async_thread_pool.rb 244 def method_missing(*args, &block) 245 __value.public_send(*args, &block) 246 end
Pass all method calls to the returned result.
Source
# File lib/sequel/extensions/async_thread_pool.rb 252 def respond_to_missing?(*args) 253 __value.respond_to?(*args) 254 end
Delegate respond_to? calls to the returned result.
Private Instance Methods
Source
# File lib/sequel/extensions/async_thread_pool.rb 283 def __run_block 284 # This may not catch concurrent calls (unless surrounded by a mutex), but 285 # it's not worth trying to protect against that. It's enough to just check for 286 # multiple non-concurrent calls. 287 ::Kernel.raise Error, "Cannot run async block multiple times" unless block = @block 288 289 @block = nil 290 291 begin 292 block.call 293 rescue ::Exception => e 294 WrappedException.new(e) 295 end 296 end
Run the block and return the block value. If the block call raises an exception, wrap the exception.