use of suite.primitive.FltPrimitives.FltSink in project suite by stupidsing.
the class FltOutlet method sink.
public void sink(FltSink sink0) {
FltSink sink1 = sink0.rethrow();
float c;
while ((c = next()) != FltFunUtil.EMPTYVALUE) sink1.sink(c);
}
use of suite.primitive.FltPrimitives.FltSink in project suite by stupidsing.
the class FltFunUtil method suck.
/**
* Sucks data from a sink and produce into a source.
*/
public static FltSource suck(Sink<FltSink> fun) {
NullableSyncQueue<Float> queue = new NullableSyncQueue<>();
FltSink 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