def process_events
      until @dead
        @mutex.synchronize do
          while @queue.empty?
            break if @dead
            @not_empty.wait(@mutex)
          end
          event = @queue.pop
          break unless event
          notify_listeners(event)
          event.dispatch
        end
      end
    rescue Exception => ex
      Logger.error "Error while running event: #{Logger.format_error(ex)}"
    end
def process_events
      until @dead
        @mutex.synchronize do
          while @queue.empty?
            break if @dead
            @not_empty.wait(@mutex)
          end
          event = @queue.pop
          break unless event
          notify_listeners(event)
          event.dispatch
        end
      end
    rescue Exception => ex
      Logger.error "Error while running event: #{Logger.format_error(ex)}"
    end
Process all the events

 @return [Thread]

 @api private