Beispiel #1
0
    void complete(int id) {
      List<Object> localQueue;
      synchronized (guard) {
        if (id != index) {
          return;
        }
        active = false;
        if (!mainDone) {
          return;
        }
        if (emitting) {
          if (queue == null) {
            queue = new ArrayList<Object>();
          }
          queue.add(nl.completed());
          return;
        }

        localQueue = queue;
        queue = null;
        emitting = true;
      }

      drain(localQueue);
      serializedChild.onCompleted();
      unsubscribe();
    }
Beispiel #2
0
 void emit(T value, int id, InnerSubscriber<T> innerSubscriber) {
   List<Object> localQueue;
   synchronized (guard) {
     if (id != index) {
       return;
     }
     if (emitting) {
       if (queue == null) {
         queue = new ArrayList<Object>();
       }
       queue.add(value);
       return;
     }
     localQueue = queue;
     queue = null;
     emitting = true;
   }
   boolean once = true;
   boolean skipFinal = false;
   try {
     do {
       drain(localQueue);
       if (once) {
         once = false;
         serializedChild.onNext(value);
         arbiter.produced(1);
       }
       synchronized (guard) {
         localQueue = queue;
         queue = null;
         if (localQueue == null) {
           emitting = false;
           skipFinal = true;
           break;
         }
       }
     } while (!serializedChild.isUnsubscribed());
   } finally {
     if (!skipFinal) {
       synchronized (guard) {
         emitting = false;
       }
     }
   }
 }
Beispiel #3
0
 void drain(List<Object> localQueue) {
   if (localQueue == null) {
     return;
   }
   for (Object o : localQueue) {
     if (nl.isCompleted(o)) {
       serializedChild.onCompleted();
       break;
     } else if (nl.isError(o)) {
       serializedChild.onError(nl.getError(o));
       break;
     } else {
       @SuppressWarnings("unchecked")
       T t = (T) o;
       serializedChild.onNext(t);
       arbiter.produced(1);
     }
   }
 }
Beispiel #4
0
    void error(Throwable e, int id) {
      List<Object> localQueue;
      synchronized (guard) {
        if (id != index) {
          return;
        }
        if (emitting) {
          if (queue == null) {
            queue = new ArrayList<Object>();
          }
          queue.add(nl.error(e));
          return;
        }

        localQueue = queue;
        queue = null;
        emitting = true;
      }

      drain(localQueue);
      serializedChild.onError(e);
      unsubscribe();
    }
Beispiel #5
0
 @Override
 public void onCompleted() {
   List<Object> localQueue;
   synchronized (guard) {
     mainDone = true;
     if (active) {
       return;
     }
     if (emitting) {
       if (queue == null) {
         queue = new ArrayList<Object>();
       }
       queue.add(nl.completed());
       return;
     }
     localQueue = queue;
     queue = null;
     emitting = true;
   }
   drain(localQueue);
   serializedChild.onCompleted();
   unsubscribe();
 }
Beispiel #6
0
 @Override
 public void onError(Throwable e) {
   serializedChild.onError(e);
   unsubscribe();
 }