Class: Manticore::IdleConnectionReaper

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/manticore/client.rb

Instance Method Summary collapse

Constructor Details

#initializeIdleConnectionReaper

Returns a new instance of IdleConnectionReaper.



654
655
656
657
658
659
660
661
662
663
664
665
# File 'lib/manticore/client.rb', line 654

def initialize
  @mutex = Mutex.new
  @pools = []
  @running = Java::JavaUtilConcurrentAtomic::AtomicBoolean.new(true)
  @thread = Thread.new do
    while @running.get
      @mutex.synchronize { @pools.each(&:closeExpiredConnections) }
      sleep 5000
    end
  end
  at_exit { shutdown }
end

Instance Method Details

#monitor(pool) ⇒ Object



667
668
669
# File 'lib/manticore/client.rb', line 667

def monitor(pool)
  @mutex.synchronize { @pools << pool }
end

#shutdownObject



671
672
673
674
# File 'lib/manticore/client.rb', line 671

def shutdown
  @running.set(false)
  @thread.wakeup
end