app/oryx-app-common/src/main/java/com/cloudera/oryx/app/als/SolverCache.java
public void compute() {
    // Make sure only one attempts to build at one time
    if (solverUpdating.compareAndSet(false, true)) {
      executor.execute(LoggingCallable.log(() -> {
        try {
          log.info("Computing cached solver");
          // Not as much hurry if one already exists
          boolean lowPriority = solver.get() != null;
          Solver newYTYSolver = LinearSystemSolver.getSolver(vectorPartitions.getVTV(lowPriority));
          if (newYTYSolver != null) {
            log.info("Computed new solver {}", newYTYSolver);
            solver.set(newYTYSolver);
          }
        } finally {
          // Allow any threads waiting for initial model to proceed.
          // It's possible the solver is still null here if there is no input.
          solverInitialized.countDown();
          solverUpdating.set(false);
        }
      }).asRunnable());
    }
  }
public void compute() {
    // Make sure only one attempts to build at one time
    if (solverUpdating.compareAndSet(false, true)) {
      executor.execute(LoggingCallable.log(() -> {
        try {
          log.info("Computing cached solver");
          // Not as much hurry if one already exists
          boolean lowPriority = solver.get() != null;
          Solver newYTYSolver = LinearSystemSolver.getSolver(vectorPartitions.getVTV(lowPriority));
          if (newYTYSolver != null) {
            log.info("Computed new solver {}", newYTYSolver);
            solver.set(newYTYSolver);
          }
        } finally {
          // Allow any threads waiting for initial model to proceed.
          // It's possible the solver is still null here if there is no input.
          solverInitialized.countDown();
          solverUpdating.set(false);
        }
      }).asRunnable());
    }
  }
public void compute ( ) { // Make sure only one attempts to build at one time if ( solverUpdating . compareAndSet ( false , true ) ) { executor . execute ( LoggingCallable . log ( ( ) -> { try { log . info ( "Computing cached solver" ) ; // Not as much hurry if one already exists boolean lowPriority = solver . get ( ) != null ; Solver newYTYSolver = LinearSystemSolver . getSolver ( vectorPartitions . getVTV ( lowPriority ) ) ; if ( newYTYSolver != null ) { log . info ( "Computed new solver {}" , newYTYSolver ) ; solver . set ( newYTYSolver ) ; } } finally { // Allow any threads waiting for initial model to proceed. // It's possible the solver is still null here if there is no input. solverInitialized . countDown ( ) ; solverUpdating . set ( false ) ; } } ) . asRunnable ( ) ) ; } }
Proactively try to compute the solver asynchronously, if not already computed.
Does not block.
Proactively try to compute the solver asynchronously if not already computed . Does not block .