public boolean addNewConsumer(
        final Consumer<T> consumer, final ProducerContext producerContext) {
      final Pair<Consumer<T>, ProducerContext> consumerContextPair =
          Pair.create(consumer, producerContext);
      T lastIntermediateResult;
      final List<ProducerContextCallbacks> prefetchCallbacks;
      final List<ProducerContextCallbacks> priorityCallbacks;
      final List<ProducerContextCallbacks> intermediateResultsCallbacks;
      final float lastProgress;
      final int lastStatus;

      // Check if Multiplexer is still in mMultiplexers map, and if so add new consumer.
      // Also store current intermediate result - we will notify consumer after acquiring
      // appropriate lock.
      synchronized (Multiplexer.this) {
        if (getExistingMultiplexer(mKey) != this) {
          return false;
        }
        mConsumerContextPairs.add(consumerContextPair);
        prefetchCallbacks = updateIsPrefetch();
        priorityCallbacks = updatePriority();
        intermediateResultsCallbacks = updateIsIntermediateResultExpected();
        lastIntermediateResult = mLastIntermediateResult;
        lastProgress = mLastProgress;
        lastStatus = mLastStatus;
      }

      BaseProducerContext.callOnIsPrefetchChanged(prefetchCallbacks);
      BaseProducerContext.callOnPriorityChanged(priorityCallbacks);
      BaseProducerContext.callOnIsIntermediateResultExpectedChanged(intermediateResultsCallbacks);

      synchronized (consumerContextPair) {
        // check if last result changed in the mean time. In such case we should not propagate it
        synchronized (Multiplexer.this) {
          if (lastIntermediateResult != mLastIntermediateResult) {
            lastIntermediateResult = null;
          } else if (lastIntermediateResult != null) {
            lastIntermediateResult = cloneOrNull(lastIntermediateResult);
          }
        }

        if (lastIntermediateResult != null) {
          if (lastProgress > 0) {
            consumer.onProgressUpdate(lastProgress);
          }
          consumer.onNewResult(lastIntermediateResult, lastStatus);
          closeSafely(lastIntermediateResult);
        }
      }

      addCallbacks(consumerContextPair, producerContext);
      return true;
    }
Tries to add consumer to set of consumers participating in multiplexing. If successful and
appropriate intermediate result is already known, then it will be passed to the consumer.

<p>This function will fail and return false if the multiplexer is not present in
mMultiplexers map.

@return true if consumer was added successfully
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/MultiplexProducer.java