Guest User

Untitled

a guest
May 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. def self.scavenger
  2. if @scavenger.nil? || !@scavenger.alive?
  3. @scavenger = Thread.new do
  4. running = true
  5. while running do
  6. puts "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  7. # Sleep before we actually start doing anything.
  8. # Otherwise we might clean up something we just made
  9. sleep(scavenger_interval)
  10.  
  11. puts "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
  12.  
  13. lock.synchronize do
  14. pools.each do |pool|
  15.  
  16. puts "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
  17.  
  18. # This is a useful check, but non-essential, and right now it breaks lots of stuff.
  19. # if pool.expired?
  20. pool.lock.synchronize do
  21.  
  22. puts "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
  23.  
  24. if pool.expired?
  25.  
  26. puts "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
  27.  
  28. v = pool.dispose
  29.  
  30. puts "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
  31.  
  32. v
  33. end
  34. end
  35. # end
  36. end
  37.  
  38. # The pool is empty, we stop the scavenger
  39. # It wil be restarted if new resources are added again
  40. if pools.empty?
  41. puts "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG"
  42. running = false
  43. puts "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH"
  44. running
  45. end
  46. end
  47. puts "Extlib::Pooling.scavenger: loop"
  48. end # loop
  49. end
  50. end
Add Comment
Please, Sign In to add comment