private void setDiscreteIfDiff(final T newValue) { T oldVal = discreteState.get(); while (!discreteState.compareAndSet(oldVal, newValue)) { oldVal = discreteState.get(); } if (!Objects.equals(oldVal, newValue)) discrete.offer(newValue); }
default ReactiveSeq<T> publishTo(Adapter<T>... adapters){ return peek(e->{ for(Adapter<T> next: adapters){ next.offer(e); } }); } default ReactiveSeq<T> publishTo(Signal<T>... signals){
/** * Set the current value of this signal * * @param newValue Replacement value * @return newValue */ public T set(final T newValue) { if(continuous!=null) continuous.offer(newValue); setDiscreteIfDiff(newValue); return newValue; }
private void setDiscreteIfDiff(final T newValue) { T oldVal = discreteState.get(); while (!discreteState.compareAndSet(oldVal, newValue)) { oldVal = discreteState.get(); } if (!Objects.equals(oldVal, newValue)) discrete.offer(newValue); }
default ReactiveSeq<T> publishTo(Adapter<T>... adapters){ return peek(e->{ for(Adapter<T> next: adapters){ next.offer(e); } }); } default ReactiveSeq<T> publishTo(Signal<T>... signals){
/** * Set the current value of this signal * * @param newValue Replacement value * @return newValue */ public T set(final T newValue) { if(continuous!=null) continuous.offer(newValue); setDiscreteIfDiff(newValue); return newValue; }
/** * Push a single value synchronously into the Adapter identified by the supplied Key, * if it exists * * <pre> * {@code * * Pipes<String,String> pipes = Pipes.of(); * pipes.register("hello", new Queue<String>()); pipes.push("hello", "world"); //on another thread pipes.reactiveSeq("hello") .getValue() .forEach(System.out::println); * * } * </pre> * * @param key Adapter key * @param value Value to push to Adapter */ public void push(final K key, final V value) { Optional.ofNullable(registered.get(key)) .ifPresent(a -> a.offer(value)); }