lib/mongo/server/connection_pool.rb
def close(options = nil)
        return if closed?

        options ||= {}

        stop_populator

        @lock.synchronize do
          until @available_connections.empty?
            connection = @available_connections.pop
            connection.disconnect!(reason: :pool_closed)
          end

          if options[:force]
            until @checked_out_connections.empty?
              connection = @checked_out_connections.take(1).first
              connection.disconnect!(reason: :pool_closed)
              @checked_out_connections.delete(connection)
            end
          end

          # mark pool as closed before releasing lock so
          # no connections can be created, checked in, or checked out
          @closed = true
        end

        publish_cmap_event(
          Monitoring::Event::Cmap::PoolClosed.new(@server.address, self)
        )

        true
      end
# Marks the pool closed, closes all idle connections in the pool and
# schedules currently checked out connections to be closed when they are
# checked back into the pool. If force option is true, checked out
# connections are also closed. Attempts to use the pool after it is closed
# will raise Error::PoolClosedError.
#
# @option options [ true | false ] :force Also close all checked out
#   connections.
#
# @return [ true ] Always true.
#
# @since 2.9.0
Marks the pool closed, closes all idle connections in the pool and
schedules currently checked out connections to be closed when they are
checked back into the pool. If force option is true, checked out
connections are also closed. Attempts to use the pool after it is closed
will raise Error::PoolClosedError.
Marks the pool closed closes all idle connections in the pool and schedules currently checked out connections to be closed when they are checked back into the pool . If force option is true checked out connections are also closed . Attempts to use the pool after it is closed will raise Error :: PoolClosedError .
def close(options = nil)
        return if closed?
        options ||= {}
        stop_populator
        @lock.synchronize do
          until @available_connections.empty?
            connection = @available_connections.pop
            connection.disconnect!(reason: :pool_closed)
          end
          if options[:force]
            until @checked_out_connections.empty?
              connection = @checked_out_connections.take(1).first
              connection.disconnect!(reason: :pool_closed)
              @checked_out_connections.delete(connection)
            end
          end
          @closed = true
        end
        publish_cmap_event(
          Monitoring::Event::Cmap::PoolClosed.new(@server.address, self)
        )
        true
      end
def close ( options = nil ) return if closed? options ||= { } stop_populator @lock . synchronize do until @available_connections . empty? connection = @available_connections . pop connection . disconnect! ( reason : :pool_closed ) end if options [ :force ] until @checked_out_connections . empty? connection = @checked_out_connections . take ( 1 ) . first connection . disconnect! ( reason : :pool_closed ) @checked_out_connections . delete ( connection ) end end @closed = true end publish_cmap_event ( Monitoring :: Event :: Cmap :: PoolClosed . new ( @server . address , self ) ) true end
Marks the pool closed, closes all idle connections in the pool and
schedules currently checked out connections to be closed when they are
checked back into the pool.
Marks the pool closed closes all idle connections in the pool and schedules currently checked out connections to be closed when they are checked back into the pool .
# mark pool as closed before releasing lock so # no connections can be created, checked in, or checked out
None
 true 
options
:force Also close all checked out connections.
: force Also close all checked out connections .
since
None