module Sequel::Database::AsyncThreadPool::DatabaseMethods

  1. lib/sequel/extensions/async_thread_pool.rb

Methods

Public Class

  1. extended

Public Class methods

extended(db)
[show source]
    # File lib/sequel/extensions/async_thread_pool.rb
339 def self.extended(db)
340   db.instance_exec do
341     case pool.pool_type
342     when :single, :sharded_single
343       raise Error, "cannot load async_thread_pool extension if using single or sharded_single connection pool"
344     end
345 
346     num_async_threads = opts[:num_async_threads] ? typecast_value_integer(opts[:num_async_threads]) : (Integer(opts[:max_connections] || 4))
347     raise Error, "must have positive number for num_async_threads" if num_async_threads <= 0
348 
349     proxy_klass = typecast_value_boolean(opts[:preempt_async_thread]) ? PreemptableProxy : Proxy
350     define_singleton_method(:async_job_class){proxy_klass}
351 
352     queue = @async_thread_queue = Queue.new
353     pool = @async_thread_pool = num_async_threads.times.map{JobProcessor.new(queue)}
354     ObjectSpace.define_finalizer(db, JobProcessor.create_finalizer(queue, pool))
355 
356     extend_datasets(DatasetMethods)
357   end
358 end