Class: Manticore::IdleConnectionReaper
- Inherits:
-
Object
- Object
- Manticore::IdleConnectionReaper
- Includes:
- Singleton
- Defined in:
- lib/manticore/client.rb
Instance Method Summary collapse
-
#initialize ⇒ IdleConnectionReaper
constructor
A new instance of IdleConnectionReaper.
- #monitor(pool) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize ⇒ IdleConnectionReaper
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 |
#shutdown ⇒ Object
671 672 673 674 |
# File 'lib/manticore/client.rb', line 671 def shutdown @running.set(false) @thread.wakeup end |