use of suite.primitive.LngPrimitives.LngSink in project suite by stupidsing.
the class LngOutlet method sink.
public void sink(LngSink sink0) {
LngSink sink1 = sink0.rethrow();
long c;
while ((c = next()) != LngFunUtil.EMPTYVALUE) sink1.sink(c);
}
use of suite.primitive.LngPrimitives.LngSink in project suite by stupidsing.
the class LngFunUtil method suck.
/**
* Sucks data from a sink and produce into a source.
*/
public static LngSource suck(Sink<LngSink> fun) {
NullableSyncQueue<Long> queue = new NullableSyncQueue<>();
LngSink 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