Exemplo n.º 1
0
  public void dropMesh(String key) {
    if (!meshes.containsKey(key)) {
      throw new NullPointerException("Tried to drop non-existing mesh!");
    }

    if (!meshes.get(key).isDone()) {
      throw new NullPointerException("Tried to drop non-finished mesh!");
    }

    Utils.getDoneFuture(meshes.get(key)).dispose();
    meshes.remove(key);
  }
Exemplo n.º 2
0
  private <T, PrepT> void compilePrepared(
      HashMap<String, Future<PrepT>> preparationQueue,
      HashMap<String, NonblockingFuture<T>> cache,
      Function<PrepT, T> uploadFunction) {
    synchronized (preparationQueue) {
      Iterator<String> prepIt = preparationQueue.keySet().iterator();

      while (prepIt.hasNext()) {
        String key = prepIt.next();
        Future<PrepT> fPrepMesh = preparationQueue.get(key);
        // Has the resource been loaded from disk an has it been
        // prepared for uploading to gpu?
        if (!fPrepMesh.isDone()) {
          continue;
        }

        // If yes to previous questions, upload the prepared resource and make
        // the future for the resource available.
        PrepT prepMesh = Utils.getDoneFuture(fPrepMesh);
        cache.get(key).set(uploadFunction.apply(prepMesh));
        prepIt.remove();
      }
    }
  }