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.



668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/manticore/client.rb', line 668

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



681
682
683
# File 'lib/manticore/client.rb', line 681

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

#shutdownObject



685
686
687
688
# File 'lib/manticore/client.rb', line 685

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