module Sequel::Plugins::ConcurrentEagerLoading::DatasetMethods
Public Instance Methods
Source
# File lib/sequel/plugins/concurrent_eager_loading.rb 124 def eager_load_concurrently 125 cached_dataset(:_eager_load_concurrently) do 126 clone(:eager_load_concurrently=>true) 127 end 128 end
Return a cloned dataset that will eager load associated results concurrently using the async thread pool.
Source
# File lib/sequel/plugins/concurrent_eager_loading.rb 133 def eager_load_serially 134 cached_dataset(:_eager_load_serially) do 135 clone(:eager_load_concurrently=>false) 136 end 137 end
Return a cloned dataset that will noteager load associated results concurrently using the async thread pool. Only useful if the current dataset has been marked as loading concurrently, or loading concurrently is the model’s default behavior.
Private Instance Methods
Source
# File lib/sequel/plugins/concurrent_eager_loading.rb 142 def eager_load_concurrently? 143 v = @opts[:eager_load_concurrently] 144 v.nil? ? model.always_eager_load_concurrently? : v 145 end
Whether this particular dataset will eager load results concurrently.
Source
# File lib/sequel/plugins/concurrent_eager_loading.rb 168 def perform_eager_load(loader, eo) 169 eo[:mutex] ? db.send(:async_run){super} : super 170 end
If performing eager loads concurrently, perform this eager load using the async thread pool.
Source
# File lib/sequel/plugins/concurrent_eager_loading.rb 151 def perform_eager_loads(eager_load_data) 152 return super if !eager_load_concurrently? || eager_load_data.length < 2 153 154 mutex = Mutex.new 155 eager_load_data.each_value do |eo| 156 eo[:mutex] = mutex 157 end 158 159 super.each do |v| 160 if Sequel::Database::AsyncThreadPool::BaseProxy === v 161 v.__value 162 end 163 end 164 end
If performing eager loads concurrently, and at least 2 associations are being eagerly loaded, create a single mutex used for all eager loads. After the eager loads have been performed, force loading of any async results, so that all eager loads will have been completed before this method returns.