Exemplo n.º 1
0
  // TODO potential concurrency problem -- late joiner may be added after failure
  public synchronized void addLateJoiner(final CacheRequest request) {

    if (cancelled) {
      request.notifyFailure(RequestFailureType.CANCELLED, null, null, "Cancelled");
      return;
    }

    if (!request.setDownload(this)) {
      notifyAllOnFailure(RequestFailureType.CANCELLED, null, null, "Cancelled");
      return;
    }

    if (request.isJson != initiator.isJson) {
      BugReportActivity.handleGlobalError(
          request.context, "Late joiner disagrees with initiator on JSON type");
      return;
    }

    lateJoiners.add(request);

    if (request.isHigherPriorityThan(highestPriorityReq)) {
      highestPriorityReq = request;
    }

    if (request.isJson) {
      if (value != null)
        request.notifyJsonParseStarted(value, RRTime.utcCurrentTimeMillis(), session, false);
    }
  }
Exemplo n.º 2
0
 public synchronized boolean isHigherPriorityThan(final CacheDownload another) {
   return highestPriorityReq.isHigherPriorityThan(another.highestPriorityReq);
 }