module Sequel::Database::AsyncThreadPool::DatasetMethods

Public Class Methods

define_async_args_or_block_method(mod, method) click to toggle source

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.

Calls superclass method
# File lib/sequel/extensions/async_thread_pool.rb, line 409
def self.define_async_args_or_block_method(mod, method)
  mod.send(:define_method, method) do |*args, &block|
    if (block || !args.empty?) && @opts[:async]
      ds = sync
      db.send(:async_run){ds.send(method, *args, &block)}
    else
      super(*args, &block)
    end
  end
end
define_async_block_method(mod, method) click to toggle source

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.

Calls superclass method
# File lib/sequel/extensions/async_thread_pool.rb, line 396
def self.define_async_block_method(mod, method)
  mod.send(:define_method, method) do |*args, &block|
    if block && @opts[:async]
      ds = sync
      db.send(:async_run){ds.send(method, *args, &block)}
    else
      super(*args, &block)
    end
  end
end
define_async_method(mod, method) click to toggle source

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

Calls superclass method
# File lib/sequel/extensions/async_thread_pool.rb, line 383
def self.define_async_method(mod, method)
  mod.send(:define_method, method) do |*args, &block|
    if @opts[:async]
      ds = sync
      db.send(:async_run){ds.send(method, *args, &block)}
    else
      super(*args, &block)
    end
  end
end

Public Instance Methods

async() click to toggle source

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

# File lib/sequel/extensions/async_thread_pool.rb, line 428
def async
  cached_dataset(:_async) do
    clone(:async=>true)
  end
end
sync() click to toggle source

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.

# File lib/sequel/extensions/async_thread_pool.rb, line 436
def sync
  cached_dataset(:_sync) do
    clone(:async=>false)
  end
end