docs: @SuppressWarnings("unchecked")
    synchronized <T> T getInternal(Resource<T> resource) {
      Instance instance = instances.get(resource);
      if (instance == null) {
        instance = new Instance(resource.create());
        instances.put(resource, instance);
      }
      if (instance.destroyTask != null) {
        instance.destroyTask.cancel(false);
        instance.destroyTask = null;
      }
      instance.refcount++;
      return (T) instance.payload;
    }