Search in sources :

Example 1 with FltSink

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);
}
Also used : FltSink(suite.primitive.FltPrimitives.FltSink)

Example 2 with FltSink

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);
        }
    };
}
Also used : Iterator(java.util.Iterator) LogUtil(suite.os.LogUtil) Source2(suite.util.FunUtil2.Source2) FltSink(suite.primitive.FltPrimitives.FltSink) Source(suite.util.FunUtil.Source) NullableSyncQueue(suite.util.NullableSyncQueue) Thread_(suite.util.Thread_) Fun(suite.util.FunUtil.Fun) Flt_Obj(suite.primitive.FltPrimitives.Flt_Obj) FltObjPair(suite.primitive.adt.pair.FltObjPair) FltObjSource(suite.primitive.FltPrimitives.FltObjSource) Sink(suite.util.FunUtil.Sink) FltTest(suite.primitive.FltPrimitives.FltTest) Collections(java.util.Collections) FltSource(suite.primitive.FltPrimitives.FltSource) Fail(suite.util.Fail) NullableSyncQueue(suite.util.NullableSyncQueue) FltSink(suite.primitive.FltPrimitives.FltSink)

Aggregations

FltSink (suite.primitive.FltPrimitives.FltSink)2 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 LogUtil (suite.os.LogUtil)1 FltObjSource (suite.primitive.FltPrimitives.FltObjSource)1 FltSource (suite.primitive.FltPrimitives.FltSource)1 FltTest (suite.primitive.FltPrimitives.FltTest)1 Flt_Obj (suite.primitive.FltPrimitives.Flt_Obj)1 FltObjPair (suite.primitive.adt.pair.FltObjPair)1 Fail (suite.util.Fail)1 Fun (suite.util.FunUtil.Fun)1 Sink (suite.util.FunUtil.Sink)1 Source (suite.util.FunUtil.Source)1 Source2 (suite.util.FunUtil2.Source2)1 NullableSyncQueue (suite.util.NullableSyncQueue)1 Thread_ (suite.util.Thread_)1