Esempio n. 1
0
    public int getWidth() {
      class MyProcecure implements TObjectProcedure<PsiType> {
        int width = 0;

        public boolean execute(PsiType type) {
          if (substitute(type) != null) width++;
          return true;
        }

        public int getWidth() {
          return width;
        }
      }

      MyProcecure procedure = new MyProcecure();
      myBindings.forEachValue(procedure);
      return procedure.getWidth();
    }
 private void scheduleTimeoutCheck() {
   final Ref<Long> nextTime = Ref.create(Long.MAX_VALUE);
   synchronized (myLock) {
     if (myTimeoutHandlers.isEmpty()) return;
     myTimeoutHandlers.forEachValue(
         new TObjectProcedure<TimeoutHandler>() {
           public boolean execute(TimeoutHandler handler) {
             nextTime.set(Math.min(nextTime.get(), handler.myLastTime));
             return true;
           }
         });
   }
   final int delay = (int) (nextTime.get() - System.currentTimeMillis() + 100);
   LOG.debug("schedule timeout check in " + delay + "ms");
   if (delay > 10) {
     myTimeoutAlarm.cancelAllRequests();
     myTimeoutAlarm.addRequest(() -> checkTimeout(), delay);
   } else {
     checkTimeout();
   }
 }