use of suite.primitive.DblPrimitives.DblSink in project suite by stupidsing.
the class DblOutlet method sink.
public void sink(DblSink sink0) {
DblSink sink1 = sink0.rethrow();
double c;
while ((c = next()) != DblFunUtil.EMPTYVALUE) sink1.sink(c);
}
use of suite.primitive.DblPrimitives.DblSink in project suite by stupidsing.
the class DblFunUtil method suck.
/**
* Sucks data from a sink and produce into a source.
*/
public static DblSource suck(Sink<DblSink> fun) {
NullableSyncQueue<Double> queue = new NullableSyncQueue<>();
DblSink enqueue = c -> enqueue(queue, c);
Thread thread = Thread_.startThread(() -> {
try {
fun.sink(enqueue);
} finally {
enqueue(queue, EMPTYVALUE);
}
});
return () -> {
try {
return queue.take();
} catch (InterruptedException ex) {
thread.interrupt();
return Fail.t(ex);
}
};
}
Aggregations