Example #1
0
  private void addSaveRequest(SaveRequest r) {
    synchronized (this) {
      // some time onDestroy() execute before add save request which is
      // through
      // post runnable
      synchronized (mSaveServiceObject) {
        if (mSaverService == null) {
          Log.e(TAG, "[addSaveRequest]mSaverService is null,return.");
          return;
        }

        while (mSaverService.getWaitingCount() >= QUEUE_LIMIT) {
          try {
            Log.i(TAG, "[addSaveRequest],waiting count > QUEUE_LIMIT 100,wait...");
            wait();
          } catch (InterruptedException ex) {
            // ignore.
            Log.e(TAG, "[addSaveRequest]exception:", ex);
          }
        }
        Log.i(TAG, "[addSaveRequest]mSaverService.addSaveRequest...");
        mSaverService.addSaveRequest(r);
      }
    }
  }
Example #2
0
 public int getWaitingCount() {
   Log.d(TAG, "[getWaitingCount]...");
   if (mSaverService == null) {
     Log.e(TAG, "[getWaitingCount]mSaverService is null,return!");
     return -1;
   }
   return mSaverService.getWaitingCount();
 }