123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::AsynchronousQueriesTracker::Session

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: activerecord/lib/active_record/asynchronous_queries_tracker.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newSession

[ GitHub ]

  
# File 'activerecord/lib/active_record/asynchronous_queries_tracker.rb', line 9

def initialize
  @active = Concurrent::AtomicBoolean.new(true)
  @lock = Concurrent::ReadWriteLock.new
end

Instance Attribute Details

#active?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/asynchronous_queries_tracker.rb', line 14

def active?
  @active.true?
end

Instance Method Details

#finalize(wait = false)

[ GitHub ]

  
# File 'activerecord/lib/active_record/asynchronous_queries_tracker.rb', line 22

def finalize(wait = false)
  @active.make_false
  if wait
    # Wait until all thread with a read lock are done
    @lock.with_write_lock { }
  end
end

#synchronize(&block)

[ GitHub ]

  
# File 'activerecord/lib/active_record/asynchronous_queries_tracker.rb', line 18

def synchronize(&block)
  @lock.with_read_lock(&block)
end