@Override
 public synchronized void shutdown() {
   for (TitanTransaction tx : openTx.keySet()) {
     tx.commit();
   }
   openTx.clear();
   txs = null;
 }
 public static void onDestroyActivity() {
   HashSet<Animator> animators = new HashSet<Animator>(sAnimators.keySet());
   for (Animator a : animators) {
     if (a.isRunning()) {
       a.cancel();
     }
     sAnimators.remove(a);
   }
 }
 @Override
 protected void finalize() throws Throwable {
   adapterCleanupThread.stopCleaner();
   for (ResourceSet rs : resourceSets.keySet()) {
     if (rs != null && adapter != null) {
       rs.eAdapters().remove(adapter);
     }
   }
   super.finalize();
 }
 /**
  * Передает сообщение подписчикам
  *
  * @param ev сообщение
  */
 public void fireEvent(Event ev) {
   synchronized (syncObj) {
     for (Listner l : listeners) {
       if (l != null) l.execlDataWriterEvent(ev);
     }
     for (Listner l : weakListeners.keySet()) {
       if (l != null) l.execlDataWriterEvent(ev);
     }
   }
 }
  /**
   * Collects statistics about database connection memory usage.
   *
   * @param dbStatsList The list to populate.
   */
  public void collectDbStats(ArrayList<DbStats> dbStatsList) {
    synchronized (mLock) {
      if (mAvailablePrimaryConnection != null) {
        mAvailablePrimaryConnection.collectDbStats(dbStatsList);
      }

      for (SQLiteConnection connection : mAvailableNonPrimaryConnections) {
        connection.collectDbStats(dbStatsList);
      }

      for (SQLiteConnection connection : mAcquiredConnections.keySet()) {
        connection.collectDbStatsUnsafe(dbStatsList);
      }
    }
  }
Exemple #6
0
  public static MusicDirectory.Entry findEntry(MusicDirectory.Entry entry) {
    for (UpdateView view : INSTANCES.keySet()) {
      MusicDirectory.Entry check = null;
      if (view instanceof SongView) {
        check = ((SongView) view).getEntry();
      } else if (view instanceof AlbumView) {
        check = ((AlbumView) view).getEntry();
      }

      if (check != null && entry != check && check.getId().equals(entry.getId())) {
        return check;
      }
    }

    return null;
  }
 public synchronized void clear() {
   Iterator i = new ArrayList(objects.keySet()).iterator();
   while (i.hasNext()) {
     final Object o = (Object) i.next();
     synchronized (o) {
       if (o.canRemove()) {
         RequestProcessor.Task task = (RequestProcessor.Task) tasks.get(o);
         if (task != null) {
           task.cancel();
           removeTask(o);
         }
         remove(o);
       }
     }
   }
 }
  // Can't throw.
  private void logConnectionPoolBusyLocked(long waitMillis, int connectionFlags) {
    final Thread thread = Thread.currentThread();
    StringBuilder msg = new StringBuilder();
    msg.append("The connection pool for database '").append(mConfiguration.label);
    msg.append("' has been unable to grant a connection to thread ");
    msg.append(thread.getId()).append(" (").append(thread.getName()).append(") ");
    msg.append("with flags 0x").append(Integer.toHexString(connectionFlags));
    msg.append(" for ").append(waitMillis * 0.001f).append(" seconds.\n");

    ArrayList<String> requests = new ArrayList<String>();
    int activeConnections = 0;
    int idleConnections = 0;
    if (!mAcquiredConnections.isEmpty()) {
      for (SQLiteConnection connection : mAcquiredConnections.keySet()) {
        String description = connection.describeCurrentOperationUnsafe();
        if (description != null) {
          requests.add(description);
          activeConnections += 1;
        } else {
          idleConnections += 1;
        }
      }
    }
    int availableConnections = mAvailableNonPrimaryConnections.size();
    if (mAvailablePrimaryConnection != null) {
      availableConnections += 1;
    }

    msg.append("Connections: ").append(activeConnections).append(" active, ");
    msg.append(idleConnections).append(" idle, ");
    msg.append(availableConnections).append(" available.\n");

    if (!requests.isEmpty()) {
      msg.append("\nRequests in progress:\n");
      for (String request : requests) {
        msg.append("  ").append(request).append("\n");
      }
    }

    Log.w(TAG, msg.toString());
  }
 private void invalidateToSelectWithRefsToParent(DefaultMutableTreeNode actionNode) {
   if (actionNode != null) {
     Object readyElement = myUi.getElementFor(actionNode);
     if (readyElement != null) {
       Iterator<Object> toSelect = myToSelect.keySet().iterator();
       while (toSelect.hasNext()) {
         Object eachToSelect = toSelect.next();
         if (readyElement.equals(myUi.getTreeStructure().getParentElement(eachToSelect))) {
           List<Object> children = myUi.getLoadedChildrenFor(readyElement);
           if (!children.contains(eachToSelect)) {
             toSelect.remove();
             if (!myToSelect.containsKey(readyElement)
                 && !myUi.getSelectedElements().contains(eachToSelect)) {
               addAdjustedSelection(eachToSelect, Conditions.alwaysFalse(), null);
             }
           }
         }
       }
     }
   }
 }
 public synchronized void validate() {
   // S ystem.out.println("=========================================================");
   // S ystem.out.println(this);
   // T hread.dumpStack ();
   Iterator i = new ArrayList(objects.keySet()).iterator();
   while (i.hasNext()) {
     final Object o = (Object) i.next();
     synchronized (o) {
       Task task = (Task) tasks.get(o);
       if (task != null) {
         // S ystem.out.println ("Validator.task living! " + ((AbstractVariable) o).getVariableName
         // () + " : " + o);
         continue;
       }
       task =
           RequestProcessor.postRequest(
               new Runnable() {
                 public void run() {
                   synchronized (o) {
                     if (!o.canValidate()) {
                       // S ystem.out.println ("Validator.kill task! " + ((AbstractVariable)
                       // o).getVariableName () + " : " + o);
                       removeTask(o);
                       return;
                     }
                     o.validate();
                     // S ystem.out.println ("Validator.done task! " + ((AbstractVariable)
                     // o).getVariableName () + " : " + o);
                     removeTask(o);
                   }
                 }
               });
       // S ystem.out.println ("Validator.add task! " + ((AbstractVariable) o).getVariableName () +
       // " : " + o);
       addTask(o, task);
     }
   }
   // S ystem.out.println("=========================================================");
 }
  // Might throw.
  private SQLiteConnection tryAcquirePrimaryConnectionLocked(int connectionFlags) {
    // If the primary connection is available, acquire it now.
    SQLiteConnection connection = mAvailablePrimaryConnection;
    if (connection != null) {
      mAvailablePrimaryConnection = null;
      finishAcquireConnectionLocked(connection, connectionFlags); // might throw
      return connection;
    }

    // Make sure that the primary connection actually exists and has just been acquired.
    for (SQLiteConnection acquiredConnection : mAcquiredConnections.keySet()) {
      if (acquiredConnection.isPrimaryConnection()) {
        return null;
      }
    }

    // Uhoh.  No primary connection!  Either this is the first time we asked
    // for it, or maybe it leaked?
    connection = openConnectionLocked(mConfiguration, true /*primaryConnection*/); // might throw
    finishAcquireConnectionLocked(connection, connectionFlags); // might throw
    return connection;
  }
Exemple #12
0
  private static void updateAll() {
    try {
      // If nothing can see this, stop updating
      if (activeActivities == 0) {
        activeActivities--;
        return;
      }

      List<UpdateView> views = new ArrayList<UpdateView>();
      for (UpdateView view : INSTANCES.keySet()) {
        if (view.isShown()) {
          views.add(view);
        }
      }
      if (views.size() > 0) {
        updateAllLive(views);
      } else {
        uiHandler.postDelayed(updateRunnable, 2000L);
      }
    } catch (Throwable x) {
      Log.w(TAG, "Error when updating song views.", x);
    }
  }
Exemple #13
0
 public Iterator<Thread> iterator() {
   return mWeakCollection.keySet().iterator();
 }
 @NotNull
 public Object[] getToExpand() {
   return myToExpand.keySet().toArray(new Object[myToExpand.size()]);
 }
 @NotNull
 public Object[] getToSelect() {
   return myToSelect.keySet().toArray(new Object[myToSelect.size()]);
 }
Exemple #16
0
 /**
  * Fires table change events on all registered ActivePanelListener instances.
  *
  * @param folderPanel the new active panel
  */
 private void fireActivePanelChanged(FolderPanel folderPanel) {
   for (ActivePanelListener listener : activePanelListeners.keySet())
     listener.activePanelChanged(folderPanel);
 }