module Sequel::Database::AsyncThreadPool::DatasetMethods

  1. lib/sequel/extensions/async_thread_pool.rb

Public Class methods

define_async_args_or_block_method(mod, method)

Define an method in the given module that will run the given method using an async thread if the current dataset is async and arguments or a block is provided.

[show source]
    # File lib/sequel/extensions/async_thread_pool.rb
403 def self.define_async_args_or_block_method(mod, method)
404   mod.send(:define_method, method) do |*args, &block|
405     if (block || !args.empty?) && @opts[:async]
406       ds = sync
407       db.send(:async_run){ds.send(method, *args, &block)}
408     else
409       super(*args, &block)
410     end
411   end
412 end
define_async_block_method(mod, method)

Define an method in the given module that will run the given method using an async thread if the current dataset is async and a block is provided.

[show source]
    # File lib/sequel/extensions/async_thread_pool.rb
390 def self.define_async_block_method(mod, method)
391   mod.send(:define_method, method) do |*args, &block|
392     if block && @opts[:async]
393       ds = sync
394       db.send(:async_run){ds.send(method, *args, &block)}
395     else
396       super(*args, &block)
397     end
398   end
399 end
define_async_method(mod, method)

Define an method in the given module that will run the given method using an async thread if the current dataset is async.

[show source]
    # File lib/sequel/extensions/async_thread_pool.rb
377 def self.define_async_method(mod, method)
378   mod.send(:define_method, method) do |*args, &block|
379     if @opts[:async]
380       ds = sync
381       db.send(:async_run){ds.send(method, *args, &block)}
382     else
383       super(*args, &block)
384     end
385   end
386 end

Public Instance methods

async()

Return a cloned dataset that will load results using the async thread pool.

[show source]
    # File lib/sequel/extensions/async_thread_pool.rb
422 def async
423   cached_dataset(:_async) do
424     clone(:async=>true)
425   end
426 end
sync()

Return a cloned dataset that will not load results using the async thread pool. Only used if the current dataset has been marked as using the async thread pool.

[show source]
    # File lib/sequel/extensions/async_thread_pool.rb
430 def sync
431   cached_dataset(:_sync) do
432     clone(:async=>false)
433   end
434 end