private State ensureInitialized() {
    var current = keysAndProducers;
    if (current != null) {
      return current;
    }

    synchronized (lock) {
      current = keysAndProducers;
      if (current != null) {
        return current;
      }

      var newProducers = buildState();
      keysAndProducers = newProducers;
      return newProducers;
    }
  }
private State ensureInitialized()