/** * @param stream Populate this Signal from a Stream */ public void fromStream(final Stream<T> stream) { stream.forEach(next -> set(next)); }
default ReactiveSeq<T> publishTo(Signal<T>... signals){ return peek(e->{ for(Signal<T> next: signals){ next.set(e); } }); } default ReactiveSeq<T> merge(Adapter<T>... adapters){
/** * Add a single data point to the queue * * If the queue is a bounded queue and is full, will return false * * @param data Data to add * @return true if successfully added. */ public boolean add(final T data) { try { final boolean result = queue.add((T) nullSafe(data)); if (result) { if (sizeSignal != null) this.sizeSignal.set(queue.size()); } return result; } catch (final IllegalStateException e) { return false; } }
/** * Offer a single datapoint to this Queue * * If the queue is a bounded queue and is full it will block until space comes available or until * offer time out is reached (default is Integer.MAX_VALUE DAYS). * * @param data * data to add * @return self */ @Override public boolean offer(final T data) { if (!open) { throw new ClosedQueueException(); } try { final boolean result = producerWait.offer(() -> this.queue.offer((T) nullSafe(data), this.offerTimeout, this.offerTimeUnit)); if (sizeSignal != null) this.sizeSignal.set(queue.size()); return result; } catch (final InterruptedException e) { Thread.currentThread() .interrupt(); throw ExceptionSoftener.throwSoftenedException(e); } }
this.sizeSignal.set(queue.size());
/** * @param stream Populate this Signal from a Stream */ public void fromStream(final Stream<T> stream) { stream.forEach(next -> set(next)); }
default ReactiveSeq<T> publishTo(Signal<T>... signals){ return peek(e->{ for(Signal<T> next: signals){ next.set(e); } }); } default ReactiveSeq<T> merge(Adapter<T>... adapters){
/** * Add a single data point to the queue * * If the queue is a bounded queue and is full, will return false * * @param data Data to add * @return true if successfully added. */ public boolean add(final T data) { try { final boolean result = queue.add((T) nullSafe(data)); if (result) { if (sizeSignal != null) this.sizeSignal.set(queue.size()); } return result; } catch (final IllegalStateException e) { return false; } }
/** * Offer a single datapoint to this Queue * * If the queue is a bounded queue and is full it will block until space comes available or until * offer time out is reached (default is Integer.MAX_VALUE DAYS). * * @param data * data to add * @return self */ @Override public boolean offer(final T data) { if (!open) { throw new ClosedQueueException(); } try { final boolean result = producerWait.offer(() -> this.queue.offer((T) nullSafe(data), this.offerTimeout, this.offerTimeUnit)); if (sizeSignal != null) this.sizeSignal.set(queue.size()); return result; } catch (final InterruptedException e) { Thread.currentThread() .interrupt(); throw ExceptionSoftener.throwSoftenedException(e); } }
this.sizeSignal.set(queue.size());