Class: ActiveRecord::ConnectionAdapters::FiberedMonitor::Queue
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::FiberedMonitor::Queue
- Defined in:
- lib/active_record/fiber_patches.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize ⇒ Queue
constructor
A new instance of Queue.
- #signal ⇒ Object
- #wait(timeout) ⇒ Object
Constructor Details
#initialize ⇒ Queue
Returns a new instance of Queue.
17 18 19 |
# File 'lib/active_record/fiber_patches.rb', line 17 def initialize @queue = [] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/active_record/fiber_patches.rb', line 15 def name @name end |
Instance Method Details
#signal ⇒ Object
36 37 38 39 |
# File 'lib/active_record/fiber_patches.rb', line 36 def signal fiber = @queue.pop fiber.resume(true) if fiber end |
#wait(timeout) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/active_record/fiber_patches.rb', line 21 def wait(timeout) ActiveSupport::Notifications.instrument("wait.connection_pool", :resource => self.name) do |payload| t = timeout || 5 fiber = Fiber.current x = EM::Timer.new(t) do @queue.delete(fiber) fiber.resume(false) end @queue << fiber Fiber.yield.tap do x.cancel end end end |