Beispiel #1
0
 public float generate(CA b1, CA b2, Updater u) {
   if (_frw == null) {
     _rw = new RuleWorker[WORKER_SIZE];
     _frw = new Future[_rw.length];
   }
   int workers = Math.max(1, Math.min(_rw.length, b1.getHeight() / 200));
   // workers = 1;
   int x1 = 0, y1 = 0, step = b1.getHeight() / workers;
   for (int i = 0; i < workers; i++) {
     int bot = y1 + step;
     if (i == workers - 1) {
       bot = b1.getHeight();
     }
     _rw[i] = new RuleWorker(b1, b2, x1, y1, b1.getWidth(), bot);
     _frw[i] = _pool.submit(_rw[i]);
     y1 = y1 + step;
   }
   try {
     for (int i = 0; i < workers; i++) {
       _frw[i].get();
     }
   } catch (ExecutionException e) {
     throw new Error(e);
   } catch (InterruptedException e) {
   }
   return 0f;
 }
Beispiel #2
0
 public int length() {
   return (int) Math.sqrt(super.length());
 }