diff options
Diffstat (limited to 'lib/gitlab/database/threaded_connection_pool.rb')
-rw-r--r-- | lib/gitlab/database/threaded_connection_pool.rb | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/lib/gitlab/database/threaded_connection_pool.rb b/lib/gitlab/database/threaded_connection_pool.rb deleted file mode 100644 index 1316b005741..00000000000 --- a/lib/gitlab/database/threaded_connection_pool.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Gitlab - module Database - class ThreadedConnectionPool - def self.with_pool(pool_size) - pool = new(pool_size) - - yield(pool) - - ensure - pool.join - pool.close - end - - def initialize(pool_size) - config = ActiveRecord::Base.configurations[Rails.env] - @ar_pool = ActiveRecord::Base.establish_connection( - config.merge(pool: pool_size)) - @workers = [] - @mutex = Mutex.new - end - - def execute_async(sql) - @mutex.synchronize do - @workers << Thread.new do - @ar_pool.with_connection do |connection| - connection.execute(sql) - end - end - end - end - - def join - threads = nil - - @mutex.synchronize do - threads = @workers.dup - @workers.clear - end - - threads.each(&:join) - end - - def close - @ar_pool.disconnect! - end - end - end -end |