# File lib/god/hub.rb, line 44
    def self.handle_poll(condition)
      Thread.new do
        begin
          metric = self.directory[condition]
          
          # it's possible that the timer will trigger an event before it can be cleared
          # by an exiting metric, in which case it should be ignored
          unless metric.nil?
            watch = metric.watch
            
            watch.mutex.synchronize do
              # run the test
              result = condition.test
              
              # log
              messages = self.log(watch, metric, condition, result)
              
              # notify
              if condition.notify && self.trigger?(metric, result)
                self.notify(condition, messages.last)
              end
              
              # after-condition
              condition.after
              
              # get the destination
              dest = 
              if result && condition.transition
                # condition override
                condition.transition
              else
                # regular
                metric.destination && metric.destination[result]
              end
              
              # transition or reschedule
              if dest
                # transition
                begin
                  watch.move(dest)
                rescue EventRegistrationFailedError
                  msg = watch.name + ' Event registration failed, moving back to previous state'
                  applog(watch, :info, msg)
                  
                  dest = watch.state
                  retry
                end
              else
                # reschedule
                Timer.get.schedule(condition)
              end
            end
          end
        rescue Exception => e
          message = format("Unhandled exception (%s): %s\n%s",
                           e.class, e.message, e.backtrace.join("\n"))
          applog(nil, :fatal, message)
        end
      end
    end