HolegPowerFlowContext.java 824 B

1234567891011121314151617181920212223242526272829303132333435
  1. package holeg;
  2. import holeg.model.Grid;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. public class HolegPowerFlowContext {
  6. public List<Grid> lastSolvedGrids = new ArrayList<>();
  7. public Thread solverJob;
  8. public float solverTimeMilliseconds;
  9. public Grid showGridForVisual;
  10. public void clearCache() {
  11. lastSolvedGrids.clear();
  12. }
  13. public boolean isSolving() {
  14. return solverJob != null && solverJob.isAlive();
  15. }
  16. public void stopSolver() {
  17. if (solverJob != null) {
  18. try {
  19. solverJob.interrupt();
  20. // wait till old solver job has finished or is interrupted
  21. solverJob.join(100);
  22. }
  23. catch(InterruptedException ignored) {
  24. }
  25. solverJob = null;
  26. }
  27. }
  28. }