def notify(msg)

      waiters, observers = @services.select { |n, s|
        s.respond_to?(:on_msg)
      }.sort_by { |n, s|
        n
      }.partition { |n, s|
        s.respond_to?(:wait_for)
      }

      (observers + waiters).each { |n, s| s.on_msg(msg) }
    end
def notify(msg)

      waiters, observers = @services.select { |n, s|
        s.respond_to?(:on_msg)
      }.sort_by { |n, s|
        n
      }.partition { |n, s|
        s.respond_to?(:wait_for)
      }

      (observers + waiters).each { |n, s| s.on_msg(msg) }
    end
This method is called by the worker each time it sucessfully processed
 a msg. This method calls in turn the #on_msg method for each of the
 services (that respond to that method).

 Makes sure that observers that respond to #wait_for are called last.