Beispiel #1
0
 @Override
 public Boolean execute(Object d, Receptor<Object> r, Signal parent) {
   r.lazySet(d); // put the data back in for polling
   boolean data = false;
   for (int i = 0; i < children.length; i++) {
     AtomicIntegerArray inUse = this.inUse;
     if (!inUse.compareAndSet(i, 0, 1)) {
       if (inUse.get(i) == 2) sleep();
       continue;
     }
     PooledFatPipe child = children[i];
     if (child == null) {
       inUse.set(i, 0);
       continue;
     }
     Signal signal;
     if (parent.getThreadIndex() < 0) {
       signal = new ChildSignalImpl(inUse, i);
     } else {
       ChildSignalImpl s = signals[i * poolSize + parent.getThreadIndex()];
       if (s == null || s.inUse != inUse) {
         sleep();
         inUse.set(i, 0);
         continue;
       }
       s.index = i;
       s.notified = false;
       signal = s;
     }
     try {
       data |= child.poll(signal, parent);
     } catch (Exception e) {
       if (listener == null) logger.error("poll", e);
       else listener.exceptionThrown(e);
     } finally {
       signal.signal();
     }
   }
   return data ? Boolean.TRUE : null;
 }
Beispiel #2
0
 public void start() {
   parent.start();
   Receptor<Object> parentRecptor = parent.takeReceptor();
   parentRecptor.set(new Object());
 }