lib/mongo/server/monitor.rb in mongo-2.0.6 vs lib/mongo/server/monitor.rb in mongo-2.1.0.beta

- old
+ new

@@ -89,13 +89,17 @@ @heartbeat_frequency ||= options[:heartbeat_frequency] || HEARTBEAT_FREQUENCY end # Create the new server monitor. # + # @api private + # # @example Create the server monitor. # Mongo::Server::Monitor.new(address, listeners) # + # @note Monitor must never be directly instantiated outside of a Server. + # # @param [ Address ] address The address to monitor. # @param [ Event::Listeners ] listeners The event listeners. # @param [ Hash ] options The options. # # @since 2.0.0 @@ -110,11 +114,11 @@ # Runs the server monitor. Refreshing happens on a separate thread per # server. # # @example Run the monitor. - # monito.run + # monitor.run # # @return [ Thread ] The thread the monitor runs on. # # @since 2.0.0 def run! @@ -135,9 +139,21 @@ # @return [ Boolean ] Is the Thread stopped? # # @since 2.0.0 def stop! @thread.kill && @thread.stop? + end + + # Restarts the server monitor unless the current thread is alive. + # + # @example Restart the monitor. + # monitor.restart! + # + # @return [ Thread ] The thread the monitor runs on. + # + # @since 2.1.0 + def restart! + @thread.alive? ? @thread : run! end private def average_round_trip_time(start)